Mysql returning following error when i executing query (with Group BY) for getting the result
Error Code: 1055
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'project.ws_images.wi_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
I want to get result with group by MONTH. I have searched about it and found some solution but still facing the issue. I have tried so far
SELECT * FROM `ws_images` WHERE wi_type = 'image' GROUP BY MONTH(date_added);
SELECT * FROM `ws_images` WHERE wi_type = 'image' GROUP BY DATE_FORMAT(date_added, '%Y%m');
Above both queries returning me same error which i have already mentioned. Can someone guide me where is the issue that i can fix. I would like to appreciate if someone guide me.
select *
withgroup by
shows a lack of understanding of SQL. You should provide both sample data and desired results, because your queries make no sense at all. – Gordon Linoffgroup by MONTH
doesn't make sense when you want all the other columns.group by
is usually used with aggregation functions. – Gordon LinoffORDER BY
instead and group the results as you like when you build the view.GROUP BY
in sql does not do what you think it does. – jeroen