关于SQL语句里的疑问!麻烦帮忙解释一下!
JAVA代码里有这样一句SQL语句,我想问一下里面个别 语句 的意思,希望各位不吝赐教!
select o.orgid,date_format(o.orderdate,'%Y'),count(*),sum(case when o.finalamount!='0.00' then o.finalamount else o.contractamount end)as totalmoney,sum(case when o.payamount is not NULL then o.payamount else '0.00' end) as paymoney, (sum(case when o.finalamount!='0.00' then o.finalamount else o.contractamount end)-sum(case when o.payamount is not NULL and (case when o.finalamount!='0.00' then o.finalamount else o.contractamount end)!='0.00' then o.payamount else '0.00' end)) as nopaymoney from htglview o where 1=1 and o.contractState in (5,8,9,10,11) and o.contractType='0' group by o.orgid, date_format(o.orderdate,'%Y') order by o.orgid,date_format(o.orderdate,'%Y')