1,业务说明:
报表查询数据,第一列要查询A类型数据,第二列要查询B类型数据(如A1.jpg)
日期 | 温度 | 入库量 | 出库量 |
2013/7/31 | 冷藏 | 200 | 100 |
2013/7/30 | 冷冻 | 130 | 20 |
2,sql:
SELECT 日期, 类型, 温度, 数量, company
from ((select trunc(a.estimate_date, 'dd') as 日期,
a.name as 类型,
a.category as 温度,
sum(a.moved_quantity_bu) as 数量,
a.company_id as company
from A a
group by trunc(a.estimate_date, 'dd'),
a.name,
a.category,
a.company_id) union all
(select trunc(b.intend_ship_date, 'dd') as 日期,
'出库单' as 类型,
b.category as 温度,
sum(b.shipped_quantity_bu) as 数量,
b.company_id as company
from B b
group by trunc(b.intend_ship_date, 'dd'), b.category, b.company_id))
WHERE trunc(日期, 'dd') >= ?
and trunc(日期, 'dd') <= ?
and company = ?
ORDER BY 日期, 温度
3,报表实现:
日期 | 温度 | 入库数量 | 出库数量 |
=ds1.group(日期) | =ds1.group(温度) | =ds1.select1(数量,类型=='收货单') | =ds1.select1(数量,类型=='出库单') |