I have a problem writing HQL. The problem is that I want something like this to be transferred to HQL
select
tb.aca_year,
(case when tw.isfulltime = 1 then count(te) end) as fulltime,
(case when tw.isfulltime = 0 开发者_运维问答then count(te) end) as parttime
from timetable tb, teacher te, teacherworktype tw
where .............
group by tb.aca_year
................
any suggestion please?
Best Regards,
You can do something like this:
select tb.aca_year,
sum(case when tw.isfulltime = 1 then 1 else 0 end) as fulltime,
sum(case when tw.isfulltime = 0 then 1 else 0 end) as parttime
from timetable tb, teacher te, teacherworktype tw
where .............
group by tb.aca_year ................
精彩评论