Answer the question
In order to leave comments, you need to log in
Why is there a "column must appear in the GROUP BY clause or be used in an aggregate function" error?
There are two tables:
images:
create table images
(
id serial not null
constraint images_pk
primary key,
image_url varchar(60) not null,
autor_id integer not null,
views integer,
rating numeric
);
create table votes
(
id serial not null
constraint votes_pk
primary key,
image_id integer not null,
user_id integer not null,
value integer not null
);
select image_url, (select avg(votes.value))
from images
inner join votes on votes.image_id = images.id
group by image_url
order by views asc
column "images.views" must appear in the GROUP BY clause or be used in an aggregate function. What could be the problem?
group by images.views
-column "images.image_url" must appear in the GROUP BY clause or be used in an aggregate function
Answer the question
In order to leave comments, you need to log in
This error is related to
...
order by views asc
...
order by sum(views) asc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question