I need help with a Query to get the transaction per user, I am working my way on the queries, still learning, any assistance will be appreciated.
Below Query is getting what I need for another report, pretty much transactions per Day, working good:
SELECT
date_generator.date as the_date,
IFNULL(COUNT(transactions.transaction_id), 0) as count
from (
select DATE_ADD('2021-01-01', INTERVAL (@i:=@i+1)-1 DAY) as date
from information_schema.columns,(SELECT @i:=0) gen_sub
where DATE_ADD('2021-01-01',INTERVAL @i DAY) BETWEEN '2021-01-01' AND '2021-01-12'
) date_generator
left join transactions on DATE(edited) = date_generator.date
GROUP BY date
Generates Data:
the_date count
2021-01-01 0
2021-01-02 0
2021-01-03 0
2021-01-04 12
2021-01-05 24
2021-01-06 0
2021-01-07 11
2021-01-08 0
2021-01-09 0
2021-01-10 5
2021-01-11 8
2021-01-12 3
My challenge, is that now I want the same data but per an specific username... in the same transaction table, I do have a column call username, which generates the transaction. I was playing with the Query but no luck, thanks for you assistance again.
Looking to Get... Where username = 'Test':
the_date count
2021-01-01 0
2021-01-02 0
2021-01-03 0
2021-01-04 1
2021-01-05 0
2021-01-06 0
2021-01-07 1
2021-01-08 0
2021-01-09 0
2021-01-10 0
2021-01-11 1
2021-01-12 2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…