how can format column name in case when in sql [closed]
Solution 1:
You have to use a string instead of the arithmetic expresseion:
select
count(case when DATE_FORMAT(created_at, '%Y-%c') = '2022-1' then 1 end)
as one from `users` limit 1
Your expression is the same as
select
count(case when DATE_FORMAT(created_at, '%Y-%c') = 2021 then 1 end)
as one from `users` limit 1