这个应该不是纯粹的SQL的问题。用SQL仅仅是把你所需要处理的内容取出来,然后进行处理即可!关于处理这里SQL语句应该不难吧。呵呵已经很清楚了,两个表的连接用你定义的关键字就行,然后就是取出你要的数据就行。

解决方案 »

  1.   

    我想问的是这个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