agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: 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 10:55:19 -0700 (MST)
Message-ID: <1417024519548-5828385.post@n5.nabble.com> (raw)
In-Reply-To: <CAKFQuwbyE1=iByxRiUkeBZ474_aGEBgjaKZwqQUHLOf91OT2Dg@mail.gmail.com>
References: <1416970805198-5828253.post@n5.nabble.com>
	<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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>


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
<http://postgresql.nabble.com/file/n5828385/First_time_orders.png; 

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: <1417024519548-5828385.post@n5.nabble.com>
Permalink:  ../1417024519548-5828385.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1417024519548-5828385.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: <1417024519548-5828385.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