Sunday, 1 September 2013

join two table with non-matching rows

join two table with non-matching rows

I am having two table.
one table contains customer details(i.e)
id(customerid--primary key),name,email,phonenumber
And other table contains order table(i.e)
id,customerid(foreign key),ordervalue,orderdate
I need to get the list of customers who have not ordered for last one
month(i.e) for the month of august. How can i do it.
This is the query i tried
select a.id,a.name,b.order_date from customers a
left join orders b
on a.id = b.customer_id
where b.order_date is null

No comments:

Post a Comment