I have a date column that formated and i need to group by it, how do it do this? i get this error code:Msg 8120, Level 16, State 1, Line 2Column 'o.Initials' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
here is my query:select * from(SELECT CONVERT(VARCHAR(10), AITDate, 110) AS FormatDate , TechInt as Initials , [Drug] ,[Missed PT Notes] ,[Pt Same Name] ,[PT Family] ,[Wrong PT] ,[Wrong Ques. Asked] ,[DAW] ,[Rx/Refills Omitted] ,[Allergy] ,[Wrong Sig] ,[Strength] ,[Wrong PT Address] ,[Quantity] ,[SVQ] ,[Refills] ,[Write Date] ,[Wrong MD/MD Info] ,[Rx Should be Questioned] ,[TSTF],[Non-Link Image] ,[DC Date],[Days Supply] ,[No Call Card] ,[Order Count] ,[Credit Hold Procedure] ,[Routing] ,[Sig Typo] ,[Verse Missing/Wrong] ,[Right Drug Wrong Form] ,[Others] from tblaitinfopivot (count(ercode) for ercode in ([Drug],[Missed PT Notes],[Pt Same Name],[PT Family],[Wrong PT],[Wrong Ques. Asked],[DAW],[Rx/Refills Omitted],[Allergy],[Wrong Sig],[Strength],[Wrong PT Address],[Quantity],[SVQ],[Refills],[Write Date],[Wrong MD/MD Info],[Rx Should be Questioned],[TSTF],[Non-Link Image],[DC Date],[Days Supply],[No Call Card],[Order Count],[Credit Hold Procedure],[Routing],[Sig Typo],[Verse Missing/Wrong],[Right Drug Wrong Form],[Others])) p)ogroup by formatdate