以下查询返回“表对于 JOIN 太大。考虑使用 JOIN EACH。有关更多详细信息,https://developers.google.com/bigquery/docs/query-reference#joins ”
它工作正常,直到大约 2 天前。
我确实找到了解决我不必要地使用“允许大结果”选项的其他查询的解决方法。我禁用了该选项,其他查询处理得很好。不幸的是,当我在下面的查询中执行此操作时,它会返回错误“响应太大而无法返回。”。
SELECT di.d.uid AS D_Table_UID,
di.i.uid AS I_Table_UID,
di.i.CustomerID as Customer_ID,
di.i.Route as Route,
di.i.Store as SPOT_Database,
di.d.zero AS Invoice_Line_Number,
di.i.CurrentStatus AS Invoice_Status,
di.i.Invoice_ID AS Invoice_ID,
CONCAT(di.i.CustomerID,'-',DATE( SEC_TO_TIMESTAMP(TIMESTAMP_TO_SEC(di.i.Dropoffdate)-21600))) AS Visit_ID,
IF(di.d.Category CONTAINS 'Upcharge','Upcharge','Item') AS Type,
di.d.Category AS Category,
IF(di.d.Category CONTAINS 'Upcharge', t.Item, di.d.Item) AS Item,
di.d.Item AS Item_W_UC,
IF(di.d.Category CONTAINS 'Alteration', 'Alteration', di.d.Department) AS Department,
di.i.DepartmentGroup as TEMP_Department_Group,
di.d.ItemNum AS Item_Number,
IF(di.d.Category CONTAINS 'Alteration', t.Item_Base_Piece_Count, di.d.PieceCount) AS Pieces,
di.d.Quantity AS Quantity,
IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity))) AS Price_Base,
di.i.CouponTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Coupon,
di.i.AdjustmentTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Adjustment,
di.i.DiscountTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Discount,
di.i.EnviroTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Enviro,
di.i.TaxTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Tax,
di.i.VoidTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/di.i.VoidTotal) AS Paid_Void,
di.i.WriteoffTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Writeoff,
di.i.PaidCash*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Cash,
di.i.PaidCheck*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Check,
di.i.PaidCreditCard*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Credit_Card,
di.i.PaidAccount*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Account,
di.i.PaidOther*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Other,
di.i.TotalPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Total,
di.i.TaxPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration',(di.d.Price*t.Item_Base_Quantity),(di.d.Price*di.d.Quantity)))/(di.i.Subtotal-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Paid_Tax,
di.i.CouponTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal+di.i.CouponTotal))) AS Price_Coupon1,
di.i.AdjustmentTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Price_Adjustment1,
di.i.DiscountTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Price_Discount1,
di.i.EnviroPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Price_Enviro1,
di.i.TaxPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Price_Tax1,
di.i.VoidTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/di.i.VoidTotal) AS Paid_Void1,
di.i.WriteoffTotal*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Writeoff1,
di.i.PaidCash*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Cash1,
di.i.PaidCheck*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Check1,
di.i.PaidCreditCard*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Credit_Card1,
di.i.PaidAccount*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Account1,
di.i.PaidOther*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Other1,
di.i.TotalPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration', (di.d.Price*t.Item_Base_Quantity), (di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Total1,
di.i.TaxPaid*(IF(di.d.Category CONTAINS 'Upcharge', di.d.Price,IF(di.d.Category CONTAINS 'Alteration',(di.d.Price*t.Item_Base_Quantity),(di.d.Price*di.d.Quantity)))/((di.i.TotalPaid-di.i.EnviroPaid-di.i.TaxPaid)-(di.i.DiscountTotal+di.i.AdjustmentTotal))) AS Paid_Tax1,
di.i.Modifieddate AS Date_Modified,
di.i.Dropoffdate AS Date_Dropoff,
di.i.Pickupdate AS Date_Pickup,
di.i.CompletionDate AS Date_Ready,
di.i.Paiddate AS Date_Paid,
di.i.PriceModifieddate AS Date_Price_Modified,
FROM (SELECT * FROM (SELECT * FROM SPOT.i ) AS i JOIN EACH SPOT.d AS d ON i.Invoice_ID = d.Invoice_ID ) AS di JOIN EACH SPOT.temp2 AS t ON di.i.Invoice_ID = t.Invoice_ID AND di.d.ItemNum = t.Item_Number;