日期:2014-05-16  浏览次数:20675 次

关于SQL语句里的疑问!麻烦帮忙解释一下!
JAVA代码里有这样一句SQL语句,我想问一下里面个别 语句 的意思,希望各位不吝赐教!



SQL code
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')



这里用到了hibernate3作为持久层,所以 o.orgid 就是 查询orgid这个字段,然后表的别名是 o , 是这样么? 然后这句 [color=#FF0000]from htglview o [/color] 我不太懂了,我的数据库里没有htglview这个表,那意思就是新建一个htglview的临时表存入select的数据么?


疑问就是这些,谢谢,或者哪位高手能深入的解释一下这段话,感激不尽。

------解决方案--------------------
从名字上看,可能是查询 VIEW
------解决方案--------------------
SHOW CREATE VIEW htglview
什么结果