Home > database >  Refer to SQL combined scheduling problems, thank you. - online, etc.
Refer to SQL combined scheduling problems, thank you. - online, etc.

Time:09-23


 

The select NVL (supdep, 'total') hj, sum (xj), sum (fundtype1), sum (fundtype2), sum (fundtype3) from (
The select supdep NVL (fundtype1, 0) + NVL (fundtype2, 0) + NVL (fundtype3, 0) xj, fundtype1, fundtype2, fundtype3 from (
Select '[' | | Anderson temcode | |'] '| | Anderson temname supdep, c.f undtype, sum (t.a mount) amount from ba_bgt_budget t
Left the join fp_t_ctfundtype c on t.f und_type_id=c.i temid and ep_fun_validDate (c.s. tartdate, c.e nddate, t.d byear)=1
Left the join fp_t_ctagency a on t.b gt_dept_id=Anderson temid and ep_fun_validDate (a.s tartdate, a.e nddate, t.d byear)=1
Where t.b illstatus=2 group by '[' | | Anderson temcode | |'] '| | Anderson temname, c.f undtype
) the pivot (sum (amount) for fundtype in (fundtype2 1 fundtype1, 2, 3 fundtype3)) order by supdep

) group by rollup (supdep)
The order by grouping (supdep) desc







I want to put the total row in the first row, the first one is not grouping sorting (order by grouping (supdep) desc) showed no problem, after the second row of the sequence, 101131 is what in the bottom?

Normal total line, positive sequence of reverse order is no problem,