Skip to content
Advertisement

select * from [table] where min(date) > certain date

i have a table with customers. every customers has several orders with the paid price and day he/she ordered an item. i want only customers their first order was after a certain date

orders table looks like this:

i want the customer only when the first order was after 2018-09-01, the min(date) > TO_DATE(‘2018-09-01’, ‘YYYY-MM-DD’)

result should be customers: b f

Advertisement

Answer

Use aggregation:

You don’t need to convert the date to a string for comparisons. Depending on your database, DATE may not be required.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement