i have 3 tables namely customer(cust_id,cust_name), payers(cust_id,invoice_date) , orders(cust_id,order_date) now i want to select only those customers who have order_date or invoice_date within the last 365 days from sysdate,also if i have duplicate customers with the same cust_id,cust_name who have different order_date and invoice_date and i want to eliminate the duplicate customers by selecting only distinct customers by selecting the latest order_Date or invoice_date. i am using the following query to do that, but i am unable eliminate the duplicates even while using group by.
can anyone help me with this.
select cust.cust_id,cust.cust_name,rec.order_date,pay.inv oice_date from customers cust,
recievers rec,payers pay where
cust.cust_id=rec.cust_id and cust.cust_id=pay.cust_id