两个SELECT语句之间用,连接,返回的是一个什么结果
SELECT distinct t_purchase.del_date2 as 納期,t_mtlist.model_cd1 as 製番,t_mtlist.model_cd1 as 機種1,
aa .納入枚数 ,t_delivery.del_date1 as 納入日
from t_mtlist
inner join t_purchase
on t_purchase.purchase_no = t_mtlist.order_no
inner join t_delivery
on t_delivery.purchase_no=t_mtlist.order_no
,(select t_delivery.del_date1 ,count( distinct purchase_no) as 納入枚数
from t_delivery ,t_mtlist where t_mtlist.order_no= t_delivery.purchase_no
group by t_delivery.del_date1) as aa
SELECT distinct t_purchase.del_date2 as 納期,t_mtlist.model_cd1 as 製番,t_mtlist.model_cd1 as 機種1,
aa .納入枚数 ,t_delivery.del_date1 as 納入日
from t_mtlist
inner join t_purchase
on t_purchase.purchase_no = t_mtlist.order_no
inner join t_delivery
on t_delivery.purchase_no=t_mtlist.order_no
,(select t_delivery.del_date1 ,count( distinct purchase_no) as 納入枚数
from t_delivery ,t_mtlist where t_mtlist.order_no= t_delivery.purchase_no
group by t_delivery.del_date1) as aa
select GETDATE() 納期,'aa' 製番 ,'nokia' 機種1, 222 納入枚数,GETDATE()- 0.5 納入日 union all
select GETDATE()-1 納期,'bb' 製番 ,'moto' 機種1, 333 納入枚数,GETDATE()- 1.5 納入日
),b as (
select 納入日,COUNT(納入枚数) 納入枚数 from a group by 納入日)select *
from a,(select * from b ) aa--result:
納期 製番 機種1 納入枚数 納入日 納入日 納入枚数
----------------------- ---- ----- ----------- ----------------------- ----------------------- -----------
2010-08-18 08:52:13.520 aa nokia 222 2010-08-17 20:52:13.520 2010-08-16 20:52:13.520 1
2010-08-17 08:52:13.520 bb moto 333 2010-08-16 20:52:13.520 2010-08-16 20:52:13.520 1
2010-08-18 08:52:13.520 aa nokia 222 2010-08-17 20:52:13.520 2010-08-17 20:52:13.520 1
2010-08-17 08:52:13.520 bb moto 333 2010-08-16 20:52:13.520 2010-08-17 20:52:13.520 1(4 行受影响)
番号 使用数
1 200
2 200
3 200
B 表的结构这样
序号 主序号 纳入日
1 01 2010/7/1
1 02 2010/7/1
2 03 2010/7/1
A表的主键为番号
B 表的主键为序号 主序号先要从A表取使用数,从B表取count(distinct 序号) 按日期分组
怎么实现