Question: So far i work on this code. But the main point is I want to get total customers & total wallent balance for inactive engaged
So far i work on this code. But the main point is I want to get total customers & total wallent balance for inactive engaged user. But now I only get the total wallet balance. The question is how i want to include the inactive engaged user?
with wallet_balance as ( select * from ( select userid , _id , date_trunc('day', (dateadd(hour, 8, convert(datetime,(createdat))))) as createdat_gmt8 , DATE_TRUNC('month', (dateadd(hour, 8, convert(datetime,(createdat))))) as month , walletbalance , row_number() over (partition by userid, DATE_TRUNC('month', (dateadd(hour, 8, convert(datetime,(createdat))))) order by walletbalance desc) as wb_row from public."prod-apipayments-transactions-setel-new" where status = 'success' and (createdat_gmt8 between '2021-07-31' and '2021-12-31') and walletbalance is not null ) where wb_row = 1 order by walletbalance desc )
select month , sum(walletbalance) as total_wallet_balance , count(walletbalance) as count_wallet_balance from wallet_balance where walletbalance = group by 1

Run Selected Format Selected (i) Non-select query Limit 200 I Data Table Share Download a Save month total_wallet_balance count_wallet_balance 1 Dec 01 2021 54,456,150.63 554,355 2 Nov 01 2021 49,213,581.1 523,306 3 Sep 01 2021 41,425,479.88 488,194 4 Jul 01 2021 3,407,263 52,708 5 Oct 01 2021 47,081,573.67 517,362 6 Aug 01 2021 36,674,950.93 440,273 1 - 6 of 6 1 25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
