By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

count fields over multiple rows

P: n/a
I have a database like this

id, field1,field2,field3,field4,field5

Database contains 100 rows, some rows have no fields filled, some
1field , some 2 fields etc.

How would i count the number of fields filled in total?

So the outcome is (number of fields filled in row1)+(number of fields
filled in row2)+(number of fields filled in
row3)....................+(number of fields filled in row100)

Thanx
Griemer

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
griemer wrote:
I have a database like this

id, field1,field2,field3,field4,field5

Database contains 100 rows, some rows have no fields filled, some
1field , some 2 fields etc.

How would i count the number of fields filled in total?


The COUNT() aggregate function ignores NULLs (unless you use COUNT(*)).
I assume that by "filled" you mean non-NULL, while a field not filled
has a NULL state.

SELECT COUNT(field1) + COUNT(field2) + COUNT(field3)
+ COUNT(field4) + COUNT(field5)
FROM myTable

Regards,
Bill K.
Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.