From: | Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)net> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | ORDER BY problem |
Date: | 2009-08-15 00:59:43 |
Message-ID: | 9F9A7E90-1F51-442F-BDA2-CEE8C40537E7@internode.on.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
This query selects the most recent advertisement (in table
wha_listing) for all properties (in table wha_property) and returns
the sales agency (in table wha_agency), as well as other data. The
query works as expected.
SELECT DISTINCT ON (property_id)
property_id, date, wha_property.propnum, wha_street.street_name,
wha_suburb.suburb_name, wha_agent.first_name, wha_agent.last_name,
wha_agency.name
FROM wha_listing, wha_agent, wha_agency, wha_property, wha_street,
wha_suburb
WHERE wha_suburb.id = wha_street.suburb_id
AND wha_street.id = wha_property.street_id
AND wha_property.id = property_id
AND wha_agency.id = wha_agent.agency_id
AND wha_agent.id = agent_id
AND wha_listing.date >= "2009-01-01" ORDER BY wha_listing.property_id,
wha_listing.date DESC;
I need the resulting list to be sorted by wha_agency.name
Can I do this by adding something to this query?
TIA
Michael Rowan
mike(dot)rowan(at)internode(dot)on(dot)net
11 Kingscote Street
ALBERTON
South Australia 5014
tel 618 8240 3993
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-08-15 01:09:26 | Re: ORDER BY problem |
Previous Message | P. Staring | 2009-08-14 21:18:40 | Having trouble installing on Vista |