New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove 'GROUP BY' from SQL query to comply with 'ONLY_FULL_GROUP_BY' #11
Conversation
MySQL versions >5.7.5 now have a default 'ONLY_FULL_GROUP_BY' SQL mode, so default MySQL installation will throw a wobbly: "Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns." AFAICS, 'time_id' is unique and there is only one 'temperature' set for each row, so I can't see the reason for the "MAX(temperature) as max_c" (which necessitates the 'GROUP BY') ... am I missing something? I also removed the 'seconds' from the schedules displayed as they take up valuable screen space & tell us nothing.
@artlab23 i think i have to cancel this request, i m working on weekly schedule perhaps that will simply things as well, but without group by time_id and order by start start it goes to all over the shop. Finaly Query would be: |
Out of interest, which mysql version are you using? Your query throws the same error for me: "#1055 - Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'schedule_daily_time_zone_view.tz_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by" To suppress the error, users can always disable the 'ONLY_FULL_GROUP_BY' mode Can you tell me if this query works for you: (It returns no errors on mysql 5.7.24). Happy new year, btw! ;) |
@artlab23 Server type: MariaDB |
Cheers... Ah, mariadb... So it turns out that this is a known incompatibility between mariadb and mysql , not helped by mariadb not having the 'ANY VALUE' function. I see now that multiple zones can use the same time_id, hence the need for 'GROUP_BY' (I have only 2 zones... water and heating, so I didn't spot that). I can't really see a way of coding around this issue to keep default installs of mysql and mariadb happy at the same time. In the mean time, perhaps look at your install guide(s)... there are two - this install guide shows how to install mysql, while this one give instructions on mariadb - unfortunately it's only the first one (mysql) that appears in the 'Recent Articles' sidebar and under the 'Lets Build' tab. The troubleshooting guide indicates that either db can be used. Maybe just make a note that mysql users need to disable 'ONLY_FULL_GROUP_BY' sqlmode or do the 'ANY VALUE' thing in the query? I'm up for helping out with the documentation... would a wiki here (on Github) work for you? |
@artlab23 |
Merge pull request #58 from twa127/master
@artlab23 |
can we re-open this issue. i was trying to setup my pihome on vm and i can not see schedule but when i try to rung query i get following error
and google first link is to this issue. |
@dvdcut best to open new issue for this. here is the fix for one query. SELECT any_value(sdtzv.time_id) as time_id, any_value(sdtzv.time_status) as time_status, any_value(sdtzv. |
MySQL versions >5.7.5 now have a default 'ONLY_FULL_GROUP_BY' SQL mode, so default MySQL installation will throw a wobbly:
"Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns."
AFAICS, 'time_id' is unique and there is only one 'temperature' set for each row, so I can't see the reason for the "MAX(temperature) as max_c" (which necessitates the 'GROUP BY') ... am I missing something?
I also removed the 'seconds' from the schedules displayed as they take up valuable screen space & tell us nothing.