当我运行此SQL查询时,它会忽略日期WHERE。
任何人都可以解释我做错了什么吗?尝试了一个子查询,但这也不起作用! SQL新手,但我觉得这是一个相对简单的查询有点难过。
SELECT c.Customer_No, c.Name, c.Lat, c.Lon, o.Order_ref, o.Currency,
o.Salesperson_code, o.Date, sum(o.Amount) as order_total,
count(DISTINCT o.Order_ref) as order_count
FROM navision_orders o, navision_customers c
WHERE c.Customer_No = o.Customer_No
and o.Date > '2013-01-09'
and o.Date < '2014-01-01'
GROUP BY c.Name
ORDER BY order_total DESC
LIMIT 20
答案 0 :(得分:1)
您正在使用WHERE
子句,因为您应该使用JOIN
子句。所以试试这个:
FROM navision_orders o
INNER JOIN navision_customers c ON c.Customer_No = o.Customer_No
Where o.Date > '2013-01-09' and o.Date < '2014-01-01'