Hi there
I'm wrapping up my first *really* big, complex web application, and in
doing so, I realize that my next tast will be reading some SQL books and
learning how to improve my querying. I really didn't know that i could
work math equations, comparisons, and if clauses right in the statements
themselves.
Anyways, I digress. I'm looking for a way to query the following... I have
a database full of people, where the Membership field is either a '1' or
'0'. I'd like to get the total counts for both situations in one query.
Something that will give me:
RegisteredMembe rs | 332
UnregisteredMem ber | 543
I can obviously get this result using two queries:
+
SELECT COUNT(*) AS RegisteredMembe rs FROM Contacts WHERE Membership='1'
and
SELECT COUNT(*) AS UnRegisteredMem bers FROM Contacts WHERE Membership='0'
but can I do this in one query?
THANKS!!
I'm wrapping up my first *really* big, complex web application, and in
doing so, I realize that my next tast will be reading some SQL books and
learning how to improve my querying. I really didn't know that i could
work math equations, comparisons, and if clauses right in the statements
themselves.
Anyways, I digress. I'm looking for a way to query the following... I have
a database full of people, where the Membership field is either a '1' or
'0'. I'd like to get the total counts for both situations in one query.
Something that will give me:
RegisteredMembe rs | 332
UnregisteredMem ber | 543
I can obviously get this result using two queries:
+
SELECT COUNT(*) AS RegisteredMembe rs FROM Contacts WHERE Membership='1'
and
SELECT COUNT(*) AS UnRegisteredMem bers FROM Contacts WHERE Membership='0'
but can I do this in one query?
THANKS!!
Comment