Re: generating the average 6 months spend excluding first orders

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: generating the average 6 months spend excluding first orders
Date: 2014-11-26 17:50:34
Message-ID: CAKFQuwbyE1=iByxRiUkeBZ474_aGEBgjaKZwqQUHLOf91OT2Dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Nov 26, 2014 at 10:37 AM, Ron256 [via PostgreSQL] <
ml-node+s1045698n5828381h35(at)n5(dot)nabble(dot)com> wrote:

> David,
>
> Please I need your help on getting the first time buyer.
>
> I am using the following query but I am getting incorrect results
>
>
> with cte as
> (select *,
> row_number() OVER( partition by persistent_key_str order by
> ord_submitted_date) RN
> from orders )
> select *
> from cte where rn = 1
>
> When you use this persistent_key_str = '01000217334' I get incorrect
> results.
>
> How can I resolve this?
>

​Unless you tell us what you think the correct result should be it is
impossible to know whether it is the result or your expectation that is
incorrect.

It would also help to modify your query instead of simply saying "when you
use this persistent_key_str = '...'"; show us the query that makes use of
that detail.

David J.

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ron256 2014-11-26 17:55:19 Re: generating the average 6 months spend excluding first orders
Previous Message Ron256 2014-11-26 17:37:57 Re: generating the average 6 months spend excluding first orders