Re: ranked subqueries vs distinct question - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: ranked subqueries vs distinct question
Date
Msg-id 20080514145510.GR4401@merkur.hilbert.loc
Whole thread Raw
In response to Re: ranked subqueries vs distinct question  (Decibel! <decibel@decibel.org>)
Responses Re: ranked subqueries vs distinct question
List pgsql-general
On Wed, May 14, 2008 at 09:35:10AM -0500, Decibel! wrote:

> SELECT name, zip, zip='04317' AS zipmatch
>     FROM urb LEFT JOIN streets ON (streets.urb_id = urb.urb_id )
>     ORDER BY zipmatch DESC, name
> ;

The view dem.v_zip2data (which I erronously left out in my
first post) does just that - it joins streets to urbs
thereby providing urbs with zip codes from the streets
table. It, however, only joins those rows which do have a
zip code. That leaves out those cities which don't. Which
makes me want to UNION on the dem.urb table in the initial
problem.

> Of course you'll need to adjust the table and field names appropriately.
No problem, I can do that. I am not getting the approach
right yet.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

pgsql-general by date:

Previous
From: Decibel!
Date:
Subject: Re: rounding problems
Next
From: Decibel!
Date:
Subject: Re: rounding problems