Issue
I wanted to join my tables product_sales and product. However, the product number seemed to be ambiguous. The following are my codes, kindly help me where I got it wrong. Thank you
INSERT INTO HSD_DW.PRODUCT_SALES
SELECT UNIX_TIMESTAMP(TimeID) AS TimeID, CustomerID, ProductNumber,
SUM(Quantity) AS TotalQty, UnitPrice, SUM(Quantity) * UnitPrice AS Total
FROM HSD.PRODUCT_SALES AS PS
INNER JOIN hsd.product AS P ON PS.ProductNumber = P.ProductNumber
GROUP BY TimeID, CustomerID, ProductNumber, UnitPrice
ORDER BY TimeID;
Solution
Place "PS." before reference "ProductNumber" column.
INSERT INTO HSD_DW.PRODUCT_SALES
SELECT UNIX_TIMESTAMP(TimeID) AS TimeID, CustomerID, PS.ProductNumber,
SUM(Quantity) AS TotalQty, UnitPrice, SUM(Quantity) * UnitPrice AS Total
FROM HSD.PRODUCT_SALES AS PS
INNER JOIN hsd.product AS P ON PS.ProductNumber = P.ProductNumber
GROUP BY TimeID, CustomerID, PS.ProductNumber, UnitPrice
ORDER BY TimeID;
Answered By - Ricardo Rodrigues Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.