GROUP BY error in sql

On trying to convert MySQL query to MsSql query ends in trouble.

Error states that
Column 'books.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

This code sucks
SELECT * FROM books group by books.category_id

For reference
http://sqlfiddle.com/#!3/4ed19/22

does anyone have any ideas?
Thanks in advance!

you can only select those columns which you add in group by clause. you can use subquery over here.

select * from books where CategoryID = (select Categoryid from books groupby categoryid)

Suppose consider 3 of books having same category_id let us say 2. How do you go with that..?

1 Like