pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: luisblock@amauta.rcp.net.pe
To: pgsql-sql@postgresql.org
Subject: SQL Help
Date: Wed, 05 Nov 2003 13:30:20 -0500 (GMT)
Message-ID: <1068057020.3fa941bce468d@oficina.rcp.net.pe> (raw)

PLS, help,

I am trying to JOIN two tables together with the LEFT OUTER JOIN statement, but 
with a twist:

1. table 1 id and table 2 projectid are the join field
2. Table 1 has de detail info for several ocurrences in table 2.  For each id 
in table 1 (project detail), there are many entries of projectid on table 2 
(update log on project)
3. I need a query that gets each project detail (table 1) with ONLY the LAST 
(most recent) update date and comment (table 2) for that project.

The result report will look something like this:

Repeat____________________________________________________
PROJECT NAME(table 1)   PROJECT DATE(table 1)    PROJECT OWNER(table 1)
LAST UPDATE(table 2)    LAST UPDATE COMMENT(table 2)
Repeat_____________________________________________________

I have used the SELECT TOP 1 function, the DISTINCT function, I am out of ideas.

Thanx

LuisFe



view thread (9+ messages)

Message-ID: <1068057020.3fa941bce468d@oficina.rcp.net.pe>
Permalink:  ../1068057020.3fa941bce468d@oficina.rcp.net.pe/
Also on:    postgresql.org/message-id/1068057020.3fa941bce468d@oficina.rcp.net.pe

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: luisblock@amauta.rcp.net.pe
  Subject: Re: SQL Help
  In-Reply-To: <1068057020.3fa941bce468d@oficina.rcp.net.pe>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox