Re: generating the average 6 months spend excluding first orders

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: generating the average 6 months spend excluding first orders
Дата
Msg-id CAKFQuwafwdV3uqWgFy-ChXtdCO46WG+96yM2TCf9y4NBZGNOew@mail.gmail.com
обсуждение исходный текст
Ответ на Re: generating the average 6 months spend excluding first orders  (Ron256 <ejaluronaldlee@gmail.com>)
Ответы Re: generating the average 6 months spend excluding first orders  (Ron256 <ejaluronaldlee@gmail.com>)
Список pgsql-sql
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_dateMy output

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...​

David J.



View this message in context: Re: generating the average 6 months spend excluding first orders
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

В списке pgsql-sql по дате отправления:

Предыдущее
От: Ron256
Дата:
Сообщение: Re: generating the average 6 months spend excluding first orders
Следующее
От: Ron256
Дата:
Сообщение: Re: generating the average 6 months spend excluding first orders