I have request number created each month, I need to create sql query to show the count of request created for last 5 months, there might be scenario when no request is created but sql query should show that month with value as zero.
Below is the query which I am using it but it is not giving expected result:
With T1 as ( Select Ser# , month(TIMESTAMP_FORMAT(CHAR(DCR),'YYYYMMDD')) as MName FROM Lib/Mytable where date(TIMESTAMP_FORMAT(CHAR(DCR),'YYYYMMDD')) >= date(current_date - 4 month))
Select Count(*) , MName from T1 Group By Mname Order By Mname
This above query will giving me result as
I want my result should look like this
Any suggestion what changes I need to make to above query or how can I modify above query which will give me expected result. DCR field is decimal in YYYYMMDD Format.
Discussions relating to writing software in ILE RPG (RPG IV). This includes both fixed and free format RPG.
1 post • Page 1 of 1