pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dino Vliet <dino_vliet@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: only last records in subgroups
Date: Tue, 17 Aug 2004 03:44:37 -0700 (PDT)
Message-ID: <20040817104437.93301.qmail@web40110.mail.yahoo.com> (raw)

Hi there,

I'm having hard times with the following query:
I want to select only the last records from a subgroup
in a table. But because the subgroup contains
different number of records for every id, I don't know
how to specify that. For example, check the following
table,
id, day
x,300
x,250,
x,0
y,250
y,4

I only want the records
x,0 and y,4 but how do I manage this in sql? I was
hoping for a keyword LAST or so, where I can specify
that when I've ordered my results with order by, I
could only get the last of the subgroups (the first
one is easy because I could use limit 1)

Thanks in advance


	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 



view thread (3+ messages)  latest in thread

Message-ID: <20040817104437.93301.qmail@web40110.mail.yahoo.com>
Permalink:  ../20040817104437.93301.qmail@web40110.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040817104437.93301.qmail@web40110.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dino_vliet@yahoo.com
  Subject: Re: only last records in subgroups
  In-Reply-To: <20040817104437.93301.qmail@web40110.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox