1

I got a database contain employee name and month days in front of it

id         name        1    2       3     4
-----      ------      ---  --     ---    ---
1          Mark        half  full  full   half

i would like to count the number of columns which contain value half and number of columns which contain full value

like if i want to count null values i write

select is null(`1`)+ is null (`2`) as count from employee where id = 280

so what should i do or which query can solve this problem for me

4

1 回答 1

1
SELECT  (`1` = 'half') + (`2` = 'half') + (`3` = 'half') + (`4` = 'half') AS `HALF`,
        (`1` = 'full') + (`2` = 'full') + (`3` = 'full') + (`4` = 'full') AS `FULL`
FROM    TableName
-- WHERE condition here
于 2013-04-21T14:59:12.770 回答