Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- count fields over multiple rows
November 15, 2005, 10:34 am
rate this thread
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)
Re: count fields over multiple rows
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)
- » I need help with selecting from 2 identical tables in 2 separate databases
- — Next thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum