-- Q5: Pull all the order details of Product
-- (ID: 657768) got sold at a discount rate of 0.06
SELECT * FROM superstore.orders JOIN
superstore.product ON
superstore.orders.ProductID=superstore.product.ProductID
WHERE
superstore.product.ProductID='657768' AND Discount='0.06';
这会给我一个空记录。我该如何解决?
答案 0 :(得分:0)
wb = ThisWorkBook
sh = "Sheet1" <-- whatever your sheet name is
答案 1 :(得分:0)
在SELECT查询中使用列名而不是&#34; *&#34;这一点很重要。因为如果你有数千条记录的表格会变慢。
SELECT
p.ProductID,p.ProductName,p.ProductCategory,p.ProductSubCategory,
p.ProductContainer,p.ProductBaseMargin
FROM Product p
JOIN Orders o ON o.ProductID = p.ProductID
WHERE p.ProductID = '657768' AND o.Discount=0.06