I am trying to run a query where I would get the month and the total for each month
Below is the query that I am running but I am getting the following error
"Msg 145, Level 15, State 1, Line 2
ORDER BY items must appear in the select list if SELECT DISTINCT is specified."
select distinct month(transdatetime)as month,sum(sales)as total from btheader
group by transdatetime,sales,warehouseno
order by transdatetime,sales,warehouseno
What is it that I am doing wrong ?