Link to home
Create AccountLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

sql statement for count in mysql

SELECT `Ssurname`
, SUM(CASE WHEN ((`status`= '11' ) or  (`status`= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_11
, SUM(CASE WHEN ((`status`!= '11' ) AND(`status`!= '12' ) ) THEN 1 ELSE 0 END) as Rows_Status_not_11,(select  count(*) as tol where ( (`status`= '11' ) or  (`status`= '12' )) form member_copy1 )
from member_copy1
GROUP BY `Ssurname`
Order by Rows_Status_11 Desc

sql above is not work please help to correct it

may be (select  count(*) as tol where ( (`status`= '11' ) or  (`status`= '12' )) form member_copy1 ) is not correct
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.