Postgres Joins ?

From: Tony Wade <postgres(at)wade(dot)co(dot)za>
To: pgsql-novice(at)postgresql(dot)org
Subject: Postgres Joins ?
Date: 2007-10-23 22:05:25
Message-ID: 20071023220525.GL4681@postman.stonemanor.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

Would someone be able to assist with the following Postgres Query.

select t.id,q.name,t.subject,u.name,t.status,t.created,t.resolved,ov.content,ov.created as Updated from tickets t, queues q, users u, objectcustomfieldvalues ov where t.created > '2007-10-02 00:00:00' AND t.queue = 6 and t.queue = q.id AND t.owner = u.id and ov.objectid = t.id and ov.customfield = 21 order by t.id;

which returns the following:

id | name | subject | name | status | created | resolved | content | updated
-------+-----------+-----------------------------------------------------------------------------------+--------------+----------+--------
12345 Fred Purchase bob Resolved 2007-10-21 14:01:23 2007-10-31 09:03:40 Captured 2007-10-21 14:03:32
12345 Fred Purchase bob Resolved 2007-10-21 14:01:23 2007-10-31 09:03:40 Released to WH 2007-10-22 07:34:01
12345 Fred Purchase bob Resolved 2007-10-21 14:01:23 2007-10-31 09:03:40 Delivered 2007-10-31 08:58:53

What I'd like to have is the following:

id | name | subject | name | status | created |captured | released to wh | delivered | resolved
12345 Fred Purchase bob Resolved 2007-10-21 14:01:23 2007-10-21 14:03:32 2007-10-22 07:34:01 2007-10-31 08:58:53 2007-10-31 09:03:40

Is this possible ? I suspect it requires the use of Joins in some manner, but my SQL knowledge is not up to scratch. I'd appreciate
it if someone could point me in the right direction.

Regards,

Tony Wade
postgres(at)wade(dot)co(dot)za

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David Monarchi 2007-10-24 02:17:23 Determine the date a table was defined/created.
Previous Message Tom Lane 2007-10-22 20:28:29 Re: Big copy slowdown