The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: Re: [OT]Shower Pumps


[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: "Dr John Tankard" <john@xxxxxxx>
  • Date: Fri, 22 Mar 2002 19:26:05 -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

John





Home | Main Index | Thread Index

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.