I want to group by service name to all my record and I am using this query in SQL Server but it's throwing an error
select max(c.service_id) as service_id, a.ser_id, b.UserID,
SQRT(POWER(69.1 * ( @latitude - b.Latitude),2) + POWER(69.1 * ( b.Longitude - @longitude ) * COS(b.Longitude / 57.3), 2)) as distance,
c.service_name
from aspnet_bawe_services a
left join aspnet_user_account b on a.bawe_id = b.UserID
left join aspnet_services_app c on a.ser_id = c.service_id
group by c.service_name
Error
Msg 8120, Level 16, State 1, Procedure app_service_list, Line 24
Column 'aspnet_bawe_services.ser_id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Copyright Notice:Content Author:「Pankaj Sharma」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44039300/group-by-is-throwing-error-in-sql-server