Re: select id,count(imdb_id) problem

From: Ntina Papadopoulou <ntina23gr(at)freemail(dot)gr>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: select id,count(imdb_id) problem
Date: 2006-04-10 06:25:58
Message-ID: 4439FA76.4020302@freemail.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

O/H Bruno Wolff III έγραψε:
> On Mon, Apr 10, 2006 at 08:52:11 +0300,
> Ntina Papadopoulou <ntina23gr(at)freemail(dot)gr> wrote:
>
>>>> select id,imdb_id,count(imdb_id) from "Movies" where id<10 group by
>>>> imdb_id;
>>>>
>> The desired result is
>> something like
>> id | imdb_id | count
>> ----+---------+-------
>> 1 | 315733 | 9
>> 10 | 335753 | 1
>> 11 | 320000 | 15
>> etc.
>>
>
> select imdb_id,count(imdb_id) from "Movies" where id<10 group by imdb_id;
> might be closer to what you want.
> However, the example that you gave doesn't match that exactly.
> Maybe if you described what you are trying to do in more detail, people could
> give you some better suggestions.
>
>
Thnx a lot!
select imdb_id,count(imdb_id) from "Movies" where id<50 group by
imdb_id; did the work

But just for learning purposes, why
select id,"Title" from "Movies" where id<15; works!
id | Title
----+------------------
1 | 21 Grams
2 | 21 Grams
3 | 21 Grams
4 | 21 Grams
5 | 21 Grams
6 | 21 Grams
7 | 21 Grams
8 | 21 Grams
9 | 21 Grams
10 | 28 Days Later...
11 | 28 Days Later...
12 | 28 Days Later...
13 | 28 Days Later...
14 | 28 Days Later...

select imdb_id,count(imdb_id) from "Movies" where id<50 group by imdb_id;
imdb_id | count
---------+-------
267248 | 3
343660 | 2
298203 | 4
315733 | 9
322259 | 12
411705 | 12
268978 | 1
289043 | 6

select "Title",imdb_id,count(imdb_id) from "Movies" where id<15 group by
imdb_id;
ERROR: column "Movies.Title" must appear in the GROUP BY clause or be
used in an aggregate function

____________________________________________________________________
http://www.freemail.gr - .
http://www.freemail.gr - free email service for the Greek-speaking.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2006-04-10 15:39:23 Re: select id,count(imdb_id) problem
Previous Message Bruno Wolff III 2006-04-10 06:07:38 Re: select id,count(imdb_id) problem