Hi @NachitoMax ,
Group by divides the query result into groups of rows, usually for the purpose of performing one or more aggregations on each group.
If you use GROUP BY without aggregation, all fields after GROUP BY must appear in the SELECT list.
You do not use aggregation in your code. At this time, all the fields after the SELECT must appear in the GROUP BY clause. Otherwise it will return the error you got.
I guess what you want is:
SELECT dbo.TBL_FinishList.prod_number,
dbo.TBL_FinishList.alias AS description,
dbo.TBL_FinishList.supplier_number,
dbo.tbl_FinishGrade.FinishType AS finish_type,
dbo.TBL_FinishList.TypeID
FROM dbo.TBL_FinishList
INNER JOIN dbo.tbl_FinishGrade
ON dbo.TBL_FinishList.gradeID = dbo.tbl_FinishGrade.ID
INNER JOIN dbo.tbl_FinishType
ON dbo.TBL_FinishList.TypeID = dbo.tbl_FinishType.id
LEFT OUTER JOIN dbo.tbl_FinishCategory
ON dbo.TBL_FinishList.categoryID = dbo.tbl_FinishCategory.ID
WHERE (dbo.TBL_FinishList.TypeID <> 0 AND TypeID = @TypeID
OR @TypeID IS NULL
AND (dbo.TBL_FinishList.active = '1'))
ORDER BY dbo.TBL_FinishList.TypeID,dbo.TBL_FinishList.seq
If this does not solve your problem, please provide a minimal example of the output you want.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.