I have the following query:
SELECT
SUM(\"balance_transactions\".\"fee\") AS sum_id
FROM \"balance_transactions\"
JOIN charges ON balance_transactions
I am coming from oracle PL/ SQL back ground. In my opinion you can use below query to use it. My understanding is that if any transaction is happening on 19-NOV-2013 1.00 AM is always going to be in 19 Nov to 20 Nov bucket so We should not worry about range I have created below query. I hope so it will help you.
SELECT DISTINCT account_id,
TRUNC(created)
||' to '
|| (TRUNC(created)+1) period,
SUM(FEE) over (partition BY account_id,TRUNC(created) ) sumid
FROM balance_transactions a,
charges b
WHERE a.source =balance_id
AND b.refunded =0
AND b.invoice IS NOT NULL
AND a.type ='charge'
ORDER BY TRUNC(created)
||' to '
|| (TRUNC(created)+1);