客户前几天,提出个需求,想进行分类汇总,但分类要求会动态的,由他们自己任意组合!现将sql分享在下,感觉用finereport来实现再好不过了!
select [?item_big|org_name?] as item_big,[?item_small|s_goods_nm?] as item_small,
sum(s_amount_z)s_amount_z,sum(s_piece_value)s_piece_value,sum(s_money)s_money,sum(s_money-NVL(s_ftje,0))s_sj_money,sum(s_agio)s_agio,sum(s_ftje) s_ftje
from slv_sale_invoice a,slv_brand_site b,jc.bav_area_client_bigsmall c,slv_sale_invoice_sum_jeft d
where a.s_goods_id=b.id_key(+) and a.s_client_id=c.client_id_area(+) and
a.s_area_id=c.area_small_id(+) and a.vou_id=d.vou_id(+) and s_date>='[?star_date|2011-11-01?]' and s_date<='[?end_date|2011-12-30?]'
and nvl(s_client_id,0) like '%[?p_client_id|108761?]%' and org_code in ([?p_org_code|100004?])
and nvl(s_area_id,0) like '%[?p_area_id|108639?]%'
and s_abstract in ([?p_abstract|2?])
and nvl(s_operation_id,0) like '%[?p_operation_id|26101610?]%'
and nvl(bas_sort_nm_small,0) like '%[?p_sort_id|26101610?]%'
and 'rr'<>'[?item_big_nm|公司名称?]' and 'tt'<>'[?item_small_nm|客户名称?]'
group by [?item_big|org_name?],[?item_small|s_goods_nm?]
|