Re: max | last INET in table

From: "Peter Gibbs" <peter(at)emkel(dot)co(dot)za>
To: "Roderick A(dot) Anderson" <raanders(at)acm(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: max | last INET in table
Date: 2002-09-12 06:35:20
Message-ID: 004501c25a26$90d17b60$0b01010a@emkel.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Roderick A. Anderson wrote:

> Well this will seem strange but I'm trying to figure out a way to select
> the last INET value in a table. I found that max() isn't defined for
> inet and a max(text()) gives - obviously - an alphabetical max which is
> incorrect.
>
> Is there a function I've missed or a SQL trick to get the last IP address
> out of a table?

select <inet field> from <table> order by <inet field> desc limit 1;

This will also use an index on <inet field> if there is one, in which
case it would have been faster even if max() worked.

--
Peter Gibbs
EmKel Systems

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Fiche 2002-09-12 08:19:40 Temporary tables...
Previous Message Ross J. Reedstrom 2002-09-12 06:24:24 Re: [HACKERS] MySQL wins award - makes amusing statement