我需要显示cust_id,客户的姓名和姓氏,产品名称&lt ;-(来自产品表)和销售日期< - (来自销售表),我还需要按最近的日期顺序显示第一
这是我到目前为止所得到的:
SELECT
customer.cust_id,
customer.forename,
customer.surname,
products.prod_name,
sales.Date_of_sale
FROM customers c
INNER JOIN sales s ON c.cust_id = s.cust_id
INNER JOIN products p ON s.product_id = p.product_id
ORDER BY s.Date_of_sale DESC
任何帮助都将不胜感激。
答案 0 :(得分:0)
此
SELECT
c.cust_id,
c.forename,
c.surname,
p.prod_name,
s.Date_of_sale
FROM customers c
INNER JOIN sales s ON c.cust_id = s.cust_id
INNER JOIN products p ON s.product_id = p.product_id
ORDER BY s.Date_of_sale DESC
将起作用