Nick Stone wrote:

> Hope this helps
>
> SELECT
>       *
> FROM
>       speed_history as outside etc..
> WHERE
>       (speed = (
>               SELECT
>                       speed
>               FROM
>                       speed_history as inside etc..
>               WHERE
>                       (outside.interface = inside.interface)
>               LIMIT 1
>               ORDER BY
>                       speed DESC
>               )
>       )

Worth noting that ORDER BY speed DESC LIMIT 1 is fundamentally the same as
MAX (speed), except that MAX (speed) doesn't take advantage of any index
present.  This is a fairly common idiom but a self-described SQL Newbie may
not see the equivalence instantly.

-Owen


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to