我是Microsoft Visual Studio C#中的查询构建器,这是我到目前为止的代码,但是我想显示最新订购特定项目的客户详细信息和日期。
任何帮助都会受到赞赏,因为我陷入了困境。谢谢你的时间。
SELECT Corder.Corder_No, Corder.Customer_No, Corder.Date_Placed, Customer.Name,
Product.Product_No, Product.Description
FROM Corder
INNER JOIN Customer ON Corder.Customer_No = Customer.Custno
CROSS JOIN Product
答案 0 :(得分:0)
假设Corder-table有对product_num的引用,你可以尝试这样的事情:
SELECT DISTINCT
co.Corder_No,
co.Customer_No,
co.Date_Placed,
c.Name,
p.Product_No,
p.Description
FROM Corder co
INNER JOIN Customer c ON co.Customer_No = c.Custno
INNER JOIN Product p ON p.Product_No = co.Product_No
WHERE co.Date_Placed = (
SELECT MAX(Date_Placed)
FROM Corder co2
WHERE co2.Product_No=p.Product_No
)