Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. SELECT
  2. *
  3. FROM TableA
  4. LEFT JOIN TableB
  5. ON TableB.customer_id = TableA.customer_id
  6. ORDER BY COALESCE(TableB.payDate, '1900-01-01') DESC
  7.  
  8. select customer.customer_id, customer.first_name, customer.last_name,
  9. max(payment.payment_date)
  10. from customer
  11. left outer join payment on payment.customer_id = customer.customer_id
  12. group by customer.customer_id, customer.first_name, customer.last_name
  13. order by max(payment.payment_date) desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement