Re: [GENERAL] ranked subqueries vs distinct question

2008-05-14 Thread David McNett
On May 14, 2008, at 9:55 AM, Karsten Hilbert wrote: 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

Re: [GENERAL] ranked subqueries vs distinct question

2008-05-14 Thread David McNett
On May 14, 2008, at 9:07 AM, Karsten Hilbert wrote: That doesn't work, unfortunately, because the urb (cities) table doesn't have the zip code. That's stored in a street table which foreign keys into the urb table. The dem.v_zip2data view aggregates streets, cities, states and countries for which

Re: [GENERAL] ranked subqueries vs distinct question

2008-05-14 Thread David McNett
On May 14, 2008, at 8:15 AM, Karsten Hilbert wrote: Effectively I want known-zip cities first, then fragment-matching cities but without those already in the known-zip list. Can anyone teach me how I need to do this in SQL ? I think you've made things far more complicated than you need. How