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.kla...@aklaver.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.kla...@aklaver.com
>

Reply via email to