Returning several COUNT results from one ASP SQL statement
- by user89691
Say I have a table like this:
Field1 Field2 Field3 Field4
fred tom fred harry
tom tom
dick harry
harry
and I want to determine what proportion of it has been completed for each field.
I can execute:
SELECT COUNT (Field1) WHERE (Field1 <> '') AS Field1Count
SELECT COUNT (Field2) WHERE (Field2 <> '') AS Field2Count
SELECT COUNT (Field3) WHERE (Field3 <> '') AS Field3Count
SELECT COUNT (Field4) WHERE (Field4 <> '') AS Field4Count
Is it possible to roll up these separate SQL statements into one that will return the 4 results in one hit? Is there any performance advantage to doing so (given that the number of columns and rows may be quite large in practice)?