Re: Need help for constructing query

From: Marco <netuse(at)lavabit(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Need help for constructing query
Date: 2011-03-25 14:10:26
Message-ID: 4d8ca252$0$7654$9b4e6d93@newsspool1.arcor-online.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just want to add:

> 1) Display the rows with the highest date per id. That gives as many rows as
> ids exist.
>
> select id, max(date) from mytable group by id;
>
> gives just the id and the date, not the other values. I think of doing this
> in two steps:

select id, max(date),min,value,max from mytable group by id,min,value,max;

Gives too many rows. I don't know why. If I can manage to fix the query above
just to output one row per id I can solve it.

Marco

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-03-25 14:29:37 Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)
Previous Message Marco 2011-03-25 13:25:47 Need help for constructing query