0

I have this query which calculates the the count of total books which has same name . I wanted to select other fields like for each item I want its other columns too

SELECT name, COUNT(name)
  FROM b6j_items 
 GROUP BY name
HAVING COUNT(name) > 1
ORDER BY name desc
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • 1
    Have you tried adding the columns? Do you get any errors? – Nigel Ren May 15 '20 at 05:54
  • yes I tried adding more colums in name , columns it throws this Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'new_booksmandala.b6j_items.sku' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by – Fred Shirley May 15 '20 at 05:56
  • Imagine that you have 2 books with the same name, but different, for example, year... what value of 2 possible must be returned? and why? – Akina May 15 '20 at 06:09
  • can you add mysql sample output in your question,I think you need to use sum function – Ali Ahmad May 15 '20 at 13:14

0 Answers0