select sum(b.销售额) as total from
(
select a.货号,sum(a.数量) as 销售数量,sum(a.售价 * a.数量) as 销售额 from
(
select 货号,售价, sum(数量) as 数量 from sale_detail where --货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
union all
select 货号,售价, sum(数量) as 数量 from old_sale_detail --where 货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
) a group by a.货号
) b这个呢?和哪个一样?
(
select a.货号,sum(a.数量) as 销售数量,sum(a.售价 * a.数量) as 销售额 from
(
select 货号,售价, sum(数量) as 数量 from sale_detail where --货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
union all
select 货号,售价, sum(数量) as 数量 from old_sale_detail --where 货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
) a group by a.货号
) b这个呢?和哪个一样?
(
select a.货号,sum(a.数量) as 销售数量,sum(a.售价 * a.数量) as 销售额 from
(
select 货号,售价, sum(数量) as 数量 from sale_detail where --货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
union all
select 货号,售价, sum(数量) as 数量 from old_sale_detail where --货号 in (select product.货号 from product inner join provider on product.供应商编号=provider.供应商编号 where product.货号 like '%') and
时间 between cast('2003-10-7 00:00:00' as smalldatetime)
and cast('2003-10-7 23:00:00' as smalldatetime) group by 货号,售价
) a group by a.货号
) b