Re: generating the average 6 months spend excluding first orders - Mailing list pgsql-sql

From Ron256
Subject Re: generating the average 6 months spend excluding first orders
Date
Msg-id 1417031476188-5828414.post@n5.nabble.com
Whole thread Raw
In response to Re: generating the average 6 months spend excluding first orders  (Ron256 <ejaluronaldlee@gmail.com>)
Responses Re: generating the average 6 months spend excluding first orders
List pgsql-sql
I have modified the first query to my needs and I believe, it gives the
correct results for the first time orders. 

accept 


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_strAND  o.ord_submitted_date =
 
c.ord_date 

Thanks for your support. 

Thanks, 

Ron



--
View this message in context:
http://postgresql.nabble.com/generating-the-average-6-months-spend-excluding-first-orders-tp5828253p5828414.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Ron256
Date:
Subject: Re: generating the average 6 months spend excluding first orders
Next
From: Tim Dudgeon
Date:
Subject: Querying with arrays