如何对3列使用group by,它显示的错误是它不是按表达式分组。 这是查询。
select
brewer.name as brewer,beer.name as beer,count(ratings.score) as LowestRating
from ratings,beer,brewer
where ratings.beer=beer.id and beer.brewer=brewer.id
group by brewer,beer;
答案 0 :(得分:1)
您应该GROUP BY
按列,而不是整个表:
select
brewer.name as brewer,
beer.name as beer,
count(ratings.score) as LowestRating
from
ratings,
beer,
brewer
where
ratings.beer = beer.id
and beer.brewer = brewer.id
group by brewer.name, beer.name;