Help with field

S

SF

Hi,

I have a table for storing election result as below

CEID Autonumber
CE_CommuneID > Foreign Key to Commune Table
CE_PartyID Number Foreign Key to Party Table
CE_NumberOfVote Text
CE_NumberOfSeat Text

I use Text filed type for CE_NumberOfVotes and CE_NumberOfSeat as I want
also to display "No Candidate" in place of CE_NumberOfVote. Now I am facing
a problem of summarize the NumberOfVote and NumberOfSeat.

Could someone advice on the table structure

SF
 
S

Stefan Hoffmann

hi,
CE_NumberOfVote Text
CE_NumberOfSeat Text
I use Text filed type for CE_NumberOfVotes and CE_NumberOfSeat as I want
also to display "No Candidate" in place of CE_NumberOfVote. Now I am facing
a problem of summarize the NumberOfVote and NumberOfSeat.
Make it a Long Integer field and allow Null. If you want to store "No
Candidate" store Null, or if you need Null to indicate no entry, use a
magic number, e.g. -666.

So you can sum it

SELECT Sum(CE_NumberOfVote)
FROM Table
WHERE NOT IsNull(CE_NumberOfVote)

or

SELECT Sum(CE_NumberOfVote)
FROM Table
WHERE CE_NumberOfVote <> -666


mfG
--> stefan <--
 
S

SF

It works, Thank you

SF

Stefan Hoffmann said:
hi,

Make it a Long Integer field and allow Null. If you want to store "No
Candidate" store Null, or if you need Null to indicate no entry, use a
magic number, e.g. -666.

So you can sum it

SELECT Sum(CE_NumberOfVote)
FROM Table
WHERE NOT IsNull(CE_NumberOfVote)

or

SELECT Sum(CE_NumberOfVote)
FROM Table
WHERE CE_NumberOfVote <> -666


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top