我有一个POS(销售点)数据库,我们存储文章,条形码(eannos)和订单行(等等,但现在只使用这些)
我需要列出哪些文章以及已售出的条形码,我几乎就在那里。我似乎无法做到的唯一问题是文章上有多个条形码(如果产品颜色不同,我们会在文章中添加多个条形码,但我们只想坚持一个文章)< / p>
所以我的SQL查询是:
select Description, eanno, eannoid, sum(count) from PurchaseOrderLines
join eannos on PurchaseOrderLines.SizeColorID=EanNos.SizeColorID
where PurchaseOrderLines.articleid in (select articleid from articles where articleno in ('60321129','60314516'))
group by Description, eanno, eannoid
结果是:
Description Eanno Eannoid Sold
Top l/s AOP Baby Dark Sapphire 74 7325850944711 141588 2.00
Top l/s AOP Baby Dark Sapphire 80 7325850944735 141589 2.00
Top l/s AOP Baby Dark Sapphire 86 7325850944759 141590 4.00
Top l/s AOP Baby Dark Sapphire 92 7325850944773 141591 4.00
Bow Tie Solid Preschool Ski Patrol One size 7325851134869 141819 30.00
Bow Tie Solid Preschool Ski Patrol One size 7325851176012 142937 30.00
结果中的最后一行是重复的,只售出了30个&#34; Bow Tie Solid Preschool Ski Patrol One size&#34;但我得到了重复的行,因为它向我显示了同一篇文章的每个barcorde,并从订单行总计了数量。
如何确保只显示一条记录?