sql with the case when the query group

select transcode,sum(case when wssatus = '0000' then 1 else 0 end),sum(case when wssatus = '0000' and retnum > 0 then 1 else 0 end) from code_table where begintime > '2018-08-08' group by transcode.

Guess you like

Origin blog.csdn.net/John_Kry/article/details/90229870