On Wed, Nov 26, 2014 at 10:55 AM, Ron256 [via PostgreSQL] <[hidden email]> wrote:
David, I made a few changes to my query and looks like I am moving in the right direction I have also attached my output.
WITH first_cust_cte AS ( SELECT min(ord_submitted_date)ord_date , persistent_key_str FROM orders group by persistent_key_str ) SELECT o.persistent_key_str, o.ord_id FROM orders o INNER JOIN first_cust_cte c ON o.persistent_key_str = c.persistent_key_str WHERE ord_submitted_date = ord_date
Thanks,
Ron
Your query assumes that a person cannot place two orders on the same day - notes rows 3 & 4. If the actual date field had second or smaller precision this will probably be OK...