select a.BM_NAME,a.JT_NAME,c.WP_ID,b.MING_CHENG,b.DAN_WEI,b.PRICE,
c.NUM,c.NUM*bPRICE AS ZHONGJIA,CS
from a, b,
(select WP_ID ,sum(NUM) as NUM,count(WP_ID) AS CS
from b group by WP_ID) c
where a.LH_ID=b.LH_ID
and LH_DATE between 20071010104300 and 20071011170000
这条语句是正确的,还可以提高效率
在统计a表可以对应多个b表,所以查询出来可能有多条但是为了方便用户查看,必须把他合并成一条,统计出该数量信息
select a.BM_NAME,a.JT_NAME,b.WP_ID,b.MING_CHENG,b.DAN_WEI,b.PRICE,
b.NUM*bPRICE AS ZHONGJIA,sum(NUM) as NUM,count(WP_ID) AS CS from a, b
这就会出错