The following query successfully selects a row for every property
advertised by selling agents after a date (thanks due to this list
already).
SELECT * FROM (SELECT DISTINCT ON (property_id)
Agent.first_name, Agent.last_name, Agent.id
FROM Advertisement, Agent, Property
WHERE Property.id = Advertisement.property_id
AND Agent.id = Advertisement.agent_id
AND Advertisement.date >= '2009-01-01'
ORDER BY property_id, date DESC) ss ORDER BY Agent.last_name,
Agent.first_name;
I need to add to the query such that rather than returning a number of
identical rows for each Agent, it returns only one row per Agent and
includes each agents row-count.
Any help gratefully received. GROUP BY seems pretty tricky to use.
Michael Rowan
mike.rowan@internode.on.net
11 Kingscote Street
ALBERTON
South Australia 5014
tel 618 8240 3993