From: | April L <april(at)i-netco(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Aggregate Network Address functions? |
Date: | 2002-04-18 16:46:54 |
Message-ID: | 3.0.5.32.20020418124654.012e9b90@mail.i-netco.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I have a database of IP addresses, some of which are /8 /16 or /24 as well
as /32
I want to do a look up for the "longest" record matching an IP I enter
So the db may contain
208.253.0.0/16
as well as
208.253.55.0/24
and
208.253.55.61/32
and I want the query result to find the 208.253.61/32 record if it exists,
or the smallest netblock that contains it
I tried
SELECT MAX(ip)
FROM nlist
WHERE ip >> '208.253.55.61';
the error is Unable to select an aggregate function max(inet)
I tried
SELECT MAX(masklen(ip))
FROM nlist
WHERE ip >> '208.253.55.61';
That returns an integer of the largest mask length... such as /24 or /32.
How would I get the other fields associated with the record that has the
largest mask length?
Or, in general, how does one find the record with the largest value in a
column and get all the columns from that particular record?
This seems so basic and simple and yet I cannot think of the answer today.
Thank you,
- April
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-04-18 17:03:58 | Re: Aggregate Network Address functions? |
Previous Message | Michael McConnell | 2002-04-18 16:22:29 | SQL profiler feature in Pgsql? |