From: | Emir Ibrahimbegovic <emir(dot)ibrahimbegovic(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | chris(at)chriscurvey(dot)com, pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Inconsistent results postgresql |
Date: | 2014-07-31 13:08:07 |
Message-ID: | CABuViOyExKnL1mAkBpurJKbmmvPihm+8LU=jG7MaKRcL1sED7A@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yes there was some users subscribed at different date than payment was
made. So I used this to get the results on the daily basis :
SELECT date_trunc('day', payments.created_at) "day",
SUM("payments"."amount") AS sum_id
FROM "payments"
INNER JOIN "users" ON "users"."id" = "payments"."user_id"
WHERE "payments"."currency" = 'gbp' AND (payments.refunded_date is null)
AND
(users.deleted_at is null)
AND
(users.subscribed_at between '2014-06-30 00:00:00.000000' and '2014-07-30
23:59:59.999999')
AND
("payments"."created_at" BETWEEN '2014-07-07 00:00:00.000000' AND
'2014-07-07 23:59:59.999999')
GROUP BY 1
ORDER by 1 asc
So use the payment.created_at to for the current date and the range for the
users.subscribed_at
On Thu, Jul 31, 2014 at 9:00 AM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> On 07/31/2014 05:44 AM, Emir Ibrahimbegovic wrote:
>
>> Thank you for your response guys.
>>
>
> So, did you find the cause?
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2014-07-31 13:13:58 | Re: Inconsistent results postgresql |
Previous Message | Adrian Klaver | 2014-07-31 13:00:35 | Re: Inconsistent results postgresql |