按照列查询不同数据

1,业务说明:

报表查询数据,第一列要查询A类型数据,第二列要查询B类型数据(如A1.jpg)

日期温度入库量出库量
2013/7/31冷藏200100
2013/7/30冷冻13020

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(数量,类型=='出库单')

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值