I have a query that I am running to return some stats for my tool. Currently it is working returning all information but I have recently added a new column to be able to get the totals by location and this is where I am stuck.
Below is my query:
SELECT B.[segmentName], count(A.[segmentID]) AS total, A.[meetingID], C.[center] FROM Focus_Meetings_Segments AS A INNER JOIN Focus_Segments AS B ON A.[segmentID] = B.[id] JOIN Focus_Meetings as C ON C.[id] = A.[meetingID] WHERE C.[center] = @location GROUP BY A.[segmentID], B.[segmentName] ORDER BY total DESC FOR XML PATH ('segment'), TYPE, ELEMENTS, ROOT ('root');
The new column added was
center to the Focus_Meetings table.
The error I am getting is that meetingID is not contained in the aggregate or group by clause.
Is there another way to write this query so I can get it to run?