select a.商品编号,a.ct,b.库存数量 from (select 商品编号,count(商品编号) as ct from tbl_B group by 商品编号) a left outer join tbl_A b on a.商品编号=b.商品编号 where a.ct=5 and b.库存数量 is null
select A.商品编号 as AID,A.商品价格 as Ajiage,A.库存数量 as Akucun,B.商品编号,count(B.商品编号) as bcount from A,B where A.商品编号=B.商品编号 order by A.商品编号 desc 你直接使用这个在查询分析器里查询一下就知道了
看漏了一个条件,就是你还需要大于N或等于N select A.商品编号 as AID,A.商品价格 as Ajiage,A.库存数量 as Akucun,B.商品编号,count(B.商品编号) as bcount from A,B where A.商品编号=B.商品编号 group by B.商品编号 having (count(B.商品编号)>N)) order by A.商品编号 desc
select A.商品编号 as AID,A.商品价格 as Ajiage,A.库存数量 as Akucun,B.商品编号,count(B.商品编号) as bcount from A,B where A.商品编号=B.商品编号 group by B.商品编号 having (count(B.商品编号)>N)) order by A.商品编号 desc 使用这个,可以得到所有大于N的销售记录
select * from A where A.商品编号 in (select B.商品编号 from B group by B.商品编号 having (count(B.商品编号)=N)) 谢谢这位大哥,这个方法是可行的,但是呢,我需要的到的符合条件的是 商品编号 的一个集合 这个怎么实现 我用 select 商品编号 as x ……………… 然后用rs("x")得到的只是第一条记录的 商品编号