sql Query to Group By Year, Month, Week, Day

I tried to make a report to see a list of total records, grouped by month:


Which i found from articles:

SELECT Sum(someValues) 
FROM Table 
GROUP BY Year(date_feild), Month(date_feild), Day(date_feild) 


what i wrote first:

select count(*),Year(entered_on) ,Month(entered_on)
 from receipt_table
group by 2,3


I end up with:

select Year(entered_on) as Year,Month(entered_on) as Month,count(*)
 from receipt_table
group by 1,2
order by 1,2


any comments guys?

Comments

Popular posts from this blog

MDK Hospital opened in Horana

Disable single quote Within Forms

My Docker learning short notes