agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Ron256 <ejaluronaldlee@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: generating the average 6 months spend excluding first orders
Date: Wed, 26 Nov 2014 12:26:20 -0700 (MST)
Message-ID: <1417029980347-5828407.post@n5.nabble.com> (raw)
In-Reply-To: <1417026875109-5828394.post@n5.nabble.com>
References: <1416974013524-5828256.post@n5.nabble.com>
<1416977793450-5828259.post@n5.nabble.com>
<1417012543637-5828331.post@n5.nabble.com>
<1417023477345-5828381.post@n5.nabble.com>
<CAKFQuwbyE1=iByxRiUkeBZ474_aGEBgjaKZwqQUHLOf91OT2Dg@mail.gmail.com>
<1417024519548-5828385.post@n5.nabble.com>
<CAKFQuwafwdV3uqWgFy-ChXtdCO46WG+96yM2TCf9y4NBZGNOew@mail.gmail.com>
<1417025960949-5828390.post@n5.nabble.com>
<1417026089049-5828392.post@n5.nabble.com>
<1417026875109-5828394.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
David,
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_str AND 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-tp5828253p...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (14+ messages) latest in thread
Message-ID: <1417029980347-5828407.post@n5.nabble.com>
Permalink: ../1417029980347-5828407.post@n5.nabble.com/
Also on: postgresql.org/message-id/1417029980347-5828407.post@n5.nabble.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ejaluronaldlee@gmail.com
Subject: Re: generating the average 6 months spend excluding first orders
In-Reply-To: <1417029980347-5828407.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox