> -----Original Message-----
> From: Stacy Mader [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 2:39 AM
> To: DBI Users
> Subject: Joined Views
> 
> 
> A while back I asked about querying two tables linked by a 
> common field
> (see
> http://www.xray.mpe.mpg.de/mailing-lists/dbi/2001-02/msg00252.html).
> 
> Instead of typing alot of code,

Maybe you'll just have to go back to 'typing alot of code'. Actually
its not all that much, just a couple of queries. IF your database
won't support a view created from the below query, or if you can't
create a stored procedure to perform that query and return the
result set, then you'll have to fall back on creating two
queries (one to select from fault_no, and one to select from
response?), or just doing a simple join, but skipping duplicates
and only processing the max values from within your fetch loop.

> Select a.fault_no,
>         b.response_no,
>         b.category
>    From  report a,
>          response b
>    Where a.fault_no = b.fault_no(+)
>      ANd ( b.response_no = ( select max(response_no)
>                              from response
>                             where a.fault_no = b.fault_no )
>            or b.response_no is null
>          )

Reply via email to