我想问的是这个SQL语句如何写,这是答案:(刚从SQL版高手学习中) 不管怎样还是谢谢两位!! select a.product_style as 款式, sum(1) as 合计件数, sum(b.sales_price) as 合计金额 from product a,sales b where a.status='已售' --and from_time<sales_time<to_time --两个字段不明 --如果是参数,这么写 : and b.sales_time>@from_time and b.sales_time<@to_time and a.product_barcode=b.product_barcode and b.sales_time=(select max(sales_time) from sales where product_barcode=a.product_barcode) group by a.product_style
不管怎样还是谢谢两位!!
select
a.product_style as 款式,
sum(1) as 合计件数,
sum(b.sales_price) as 合计金额
from product a,sales b
where a.status='已售'
--and from_time<sales_time<to_time --两个字段不明
--如果是参数,这么写 : and b.sales_time>@from_time and b.sales_time<@to_time
and a.product_barcode=b.product_barcode
and b.sales_time=(select max(sales_time) from sales where product_barcode=a.product_barcode)
group by a.product_style