0

i have a dataset 'book_store' which contains table 'books' having 3 columns 'title' , 'author_fname' , 'author_lname'

i wanted to group the titles by author_lname

i wrote this query (SELECT title,author_lname FROM books GROUP BY author_lname;)

and getting this error (Error Code: 1055. Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'book_shop.books.title' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 0.000 sec).

Why i'm getting this error and what will be the correct query??

  • If you're not aggregating anything, then why use `group by`? Either group by all the columns in your SELECT, or none of the columns. – Isolated Apr 26 '23 at 17:54

0 Answers0