您的位置:首页 > 其它

一条语句轻松写出一个报表(含明细、小计、合计、总计)

2012-01-20 09:36 281 查看
select x1,x2,x3... from (

with mx as (

select x1,x2,x3,(select x4 from m where ... and rownum <2 ) x4,...

from x,y,z

where ...

)

select x1,x2,x3... from mx

union all

select x1,

x2,

'' x3,

...

sum(x7) x7,

sum(x8) x8,

sum(x9) hj

from mx

group by ROLLUP(x1, x2)

) t

order by x1,x2,x3...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐