我的简化查询如下所示:
SELECT p.product_Id,
p.productName,
s.LastSales_date
FROM products as p
LEFT OUTER JOIN
( SELECT product_id ,
max(Sales_date) as LastSales_date
FROM Sales group by product_id) as s
on s.product_id=p.product_Id
where
(s.LastSales_date is null or -- is it right?
s.LastSales_date between '2012/01/01' and '2012/01/05')
结果:
ProductName LastSalesDate
p_A 2012/01/01
p_C 2012/01/01
p_E 2012/01/02
但是有一行错过了,那一行没有sales_date,所以,如何得到如下结果:
ProductName LastSalesDate
p_A 2012/01/01
p_b <null>
p_C 2012/01/01
p_E 2012/01/02
我的问题 (null) 的行没有出现我感谢任何尝试:-)