[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
RE: [OT] SQL question
- To: <ukha_d@xxxxxxx>
- Subject: RE: [OT] SQL question
- From: "Mark Hetherington" <mark.egroups@xxxxxxx>
- Date: Fri, 22 Mar 2002 19:48:34 -0000
- Delivered-to: mailing list ukha_d@xxxxxxx
- Mailing-list: list ukha_d@xxxxxxx; contact
ukha_d-owner@xxxxxxx
- Reply-to: ukha_d@xxxxxxx
> > This should do it:
> >
> > SELECT DISTINCT ON (Parent) Parent,Date,Comment FROM child
> > ORDER BY Date DESC
> >
> > It will basically sort all rows by date then select only the
> > first row (i.e. the most recent entry). DESC is to ensure
> > that we get the latest date at the top of the resulting table
> > since SQL defaults to ASC.
> >
>
> I did not know you could do that I thought that distinct worked on all
> columns in the result set, I did not know that you could cause it to
> look at just one coloum
Seems to be PostgreSQL only unfortunately, so looks like you will be stuck
with a join. :(
Mark.
Home |
Main Index |
Thread Index
|