select b.name,
(case when pcamnt+noteamnt+serveramnt is null then 0 else pcamnt+noteamnt+serveramnt end ) as totolamnt,
(case when a.pcnum is null then 0 else a.pcnum end) pcnum,
(case when a.pcamnt is null then 0 else a.pcamnt end) pcamnt,
(case when a.notenum is null then 0 else a.notenum end) notenum,
(case when a.noteamnt is null then 0 else a.noteamnt end) noteamnt,
(case when a.servernum is null then 0 else a.servernum end) servernum,
(case when a.serveramnt is null then 0 else a.serveramnt end) serveramnt
from
(
select c.name as name,
sum(case when g.goodtype='A03020101' then g.number else 0 end) as pcnum,
sum(case when g.goodtype='A03020101' then g.budget else 0 end) as pcamnt,
sum(case when g.goodtype='A03020102' then g.number else 0 end) as notenum,
sum(case when g.goodtype='A03020102' then g.budget else 0 end) as noteamnt,
sum(case when g.goodtype='A03020103' then g.number else 0 end) as servernum,
sum(case when g.goodtype='A03020103' then g.budget else 0 end) as serveramnt
from goods as g,computer as c
where g.carcomputer is not null and g.carcomputer=c.id group by c.name
) as a full join (select name as name from computer) as b on a.name=b.name 类似这样复杂的查询,我怎么转换成 HQL Or Criteria?求教大虾了.
(case when pcamnt+noteamnt+serveramnt is null then 0 else pcamnt+noteamnt+serveramnt end ) as totolamnt,
(case when a.pcnum is null then 0 else a.pcnum end) pcnum,
(case when a.pcamnt is null then 0 else a.pcamnt end) pcamnt,
(case when a.notenum is null then 0 else a.notenum end) notenum,
(case when a.noteamnt is null then 0 else a.noteamnt end) noteamnt,
(case when a.servernum is null then 0 else a.servernum end) servernum,
(case when a.serveramnt is null then 0 else a.serveramnt end) serveramnt
from
(
select c.name as name,
sum(case when g.goodtype='A03020101' then g.number else 0 end) as pcnum,
sum(case when g.goodtype='A03020101' then g.budget else 0 end) as pcamnt,
sum(case when g.goodtype='A03020102' then g.number else 0 end) as notenum,
sum(case when g.goodtype='A03020102' then g.budget else 0 end) as noteamnt,
sum(case when g.goodtype='A03020103' then g.number else 0 end) as servernum,
sum(case when g.goodtype='A03020103' then g.budget else 0 end) as serveramnt
from goods as g,computer as c
where g.carcomputer is not null and g.carcomputer=c.id group by c.name
) as a full join (select name as name from computer) as b on a.name=b.name 类似这样复杂的查询,我怎么转换成 HQL Or Criteria?求教大虾了.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货