SQL 加入导致多个重复条目
SQL Join resulting in multiple duplicate entries
我在弄清楚如何摆脱第一个 table 的骗局时遇到了麻烦。请在此处查看突出显示的行以供参考 enter image description here
这是我输入的公式
SELECT
"Classes.Class Name" AS Customer,
"Customers.Customer Name" as docket,
"Items.Item Name" as EST_Item,
Quantity as EST_Qty,
"Unit Price" as EST_UnitPrice,
"Query_Bill Line items"."Items.Item Name" as BILL_Item,
"Query_Bill Line items"."Quantity" as Bill_Qty,
"Query_Bill Line items"."Unit Price" as Bill_UnitPrice
FROM "Query_Estimate Line Items" LEFT JOIN "Query_Bill Line Items" ON "Query_Estimate Line Items"."cUSTOMERS.cUSTOMER NAME" = "Query_Bill Line Items"."CUSTOMERS.CUSTOMER NAME"
AND "Query_Estimate Line Items"."iTEMS.ITEM NAME" = "Query_Bill Line Items"."ITEMS.ITEM NAME"
抱歉列名超长!我缺少什么来摆脱表 1 中的欺骗“"Query_Estimate Line Items"?
谢谢
要减少行数,您需要按某些内容(例如 Customer、Docket、EST_Item)进行分组,并汇总未分组的列(例如 Bill_Qty 或 Unit_Price).你知道如何使用group by吗?
我在弄清楚如何摆脱第一个 table 的骗局时遇到了麻烦。请在此处查看突出显示的行以供参考 enter image description here
这是我输入的公式
SELECT
"Classes.Class Name" AS Customer,
"Customers.Customer Name" as docket,
"Items.Item Name" as EST_Item,
Quantity as EST_Qty,
"Unit Price" as EST_UnitPrice,
"Query_Bill Line items"."Items.Item Name" as BILL_Item,
"Query_Bill Line items"."Quantity" as Bill_Qty,
"Query_Bill Line items"."Unit Price" as Bill_UnitPrice
FROM "Query_Estimate Line Items" LEFT JOIN "Query_Bill Line Items" ON "Query_Estimate Line Items"."cUSTOMERS.cUSTOMER NAME" = "Query_Bill Line Items"."CUSTOMERS.CUSTOMER NAME"
AND "Query_Estimate Line Items"."iTEMS.ITEM NAME" = "Query_Bill Line Items"."ITEMS.ITEM NAME"
抱歉列名超长!我缺少什么来摆脱表 1 中的欺骗“"Query_Estimate Line Items"?
谢谢
要减少行数,您需要按某些内容(例如 Customer、Docket、EST_Item)进行分组,并汇总未分组的列(例如 Bill_Qty 或 Unit_Price).你知道如何使用group by吗?