MdotButler
Programmer
I need to select a last activity date for a customer based on various dates stored in child records. For instance the customer has a setup_date, an order with an order_date, an invoice with an invoice_date and a payment with a payment_date. I need to present the newest date of all the dates.
I have gotten as far as the above but how do I get the greatest of the selected dates?
TIA
Mark
Code:
select customer.*,
ISNULL((select max(order_date) from orders where order.custid=customer.custid),customer.setup_date) as max_order_date,
ISNULL((select max(invoice_date) from invoice where invoice.custid=customer.custid),customer.setup_date) as max_invoice_date,
ISNULL((select max(payment_date) from payment where payment.custid=customer.custid),customer.setup_date) as max_paymentr_date
from customer
TIA
Mark