本文介绍了请指导我生成sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Table_Item ----------------------- ItemId ItemDescription SalePrice PurchasePrice StockAvailable 1饼干半角色20 17 45 2筹码30 25 35 3 Soap Lux 25 22 40 Table_ItemSoldDetail ------ -------------------------- ItemId发票#QtySold 1 1 1 2 2 1 1 2 2 1 4 1 2 5 3 3 6 1 我想从上面两张桌子上显示这个结果 物品已售出 ------------------------- 物品描述总销量 饼干半角色4 筹码4 Soap Lux 1 请指导我什么是SQL查询来生成th结果???? 谢谢解决方案 尝试: SELECT i.ItemDescriptin,SUM(isd.QtySold) FROM Table_ItemSoldDetail isd JOIN Table_Items i ON i.Id = isd。 ItemId GROUP BY isd.ItemId,i.ItemDescription 列名中的错字--OrignalGriff [/ edit] Table_Item-----------------------ItemIdItemDescription SalePrice PurchasePriceStockAvailable1Biscuit half Role20 17 452 Lays Chips 30 25 353Soap Lux 25 22 40Table_ItemSoldDetail--------------------------------ItemIdInvoice# QtySold1 1 12 2 11 2 21 4 12 5 33 6 1and I want to show this result from above two tablesItem Sold with Count-------------------------Item DescriptionTotal Qty SoldBiscuit half Role 4Lays Chips 4Soap Lux 1Please guide me what will be SQL query to generate this result ????Thanks 解决方案 Try:SELECT i.ItemDescriptin, SUM(isd.QtySold) FROM Table_ItemSoldDetail isdJOIN Table_Items iON i.Id = isd.ItemIdGROUP BY isd.ItemId, i.ItemDescription[edit]Typo in column name - OrignalGriff[/edit] 这篇关于请指导我生成sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 10:07