I just want to group some data by month and year. I don't understand why I can't output all my rows.
select distinct to_char(date_column, 'MM-YYYY') as mmyyyy
from data1
order by mmyyyy
Gives me 8 rows.
"01-2022"
"02-2022"
"03-2022"
"04-2022"
"05-2022"
"06-2022"
"07-2022"
"08-2022"
But There is also "12-2021" which is missing. If I count() it outputs '9' which should be correct so why do only 8 rows output?
select count(distinct to_char(date_column, 'MM-YYYY')) as mmyyyy
from data1
"9"
Also whether or not I include an order clause affects whether "08-2022" or "12-2021" output.
select distinct to_char(date_column, 'MM-YYYY') as mmyyyy
from data1
"04-2022"
"07-2022"
"02-2022"
"06-2022"
"12-2021"
"01-2022"
"05-2022"
"03-2022"
Am I missing something? I do not understand.