Wednesday, May 14, 2008

Re: [GENERAL] ranked subqueries vs distinct question

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: