Make the views work with the ONLY_FULL_GROUP_BY sql_mode enabled in 5.7

Make the views work with the ONLY_FULL_GROUP_BY sql_mode enabled. This is important as the mode is default in 5.7.5+.