SQL server Group by error
hi All,
I have this query I need to return Books with its category
SELECT BOOKS.NO,
BOOKS.NAME,
BOOKS.COUNTRY,
SELECTED_CATEGORY.CATEGORY_ID,
CATEGORY.CATEGORY_NAME
FROM SELECTED_CATEGORY INNER JOIN
BOOKS ON SELECTED_CATEGORY.CATEGORY_ID = BOOKS.NO INNER JOIN
CATEGORY ON SELECTED_CATEGORY.CATEGORY_ID = CATEGORY.ID
Group by BOOKS.NO;
each Book has multiple categories , i used for that purpose the group by option in SQL but it gives me an error
Msg 8120, Level 16, State 1, Line 1
Column 'BOOKS.NAME' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.