Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Select statement child - parent

Select statement child - parent

From: Yngve <msn_at_langerud.org>
Date: Fri, 05 Sep 2003 19:45:07 +0200
Message-ID: <cshhlvk8tsbjohjeucsg82r6nug8he0t8b@4ax.com>

In my example I have database with two tables:

customer contains the columns cust_id, name, address

sales contains the columns sales_id, date, value, text

When I do a

select

        c.name, s.date
from

        customer c, sales s
where

	c.cust_id=s.cust_id and
	s.date = (select 
			max(date) 
		from 
			sales ss
		where 
			ss.cust_is=c.cust_id
		)


it returns all customer name and last salesdate if they have any childrecord in tables "sales" like this:

c.name		s.date
bush		03/03/2003
jameson		02/01/2003
More		07/06/2002

So far, so good. But is it possible with a single query to return ALL customers from table customer (indepent however they have child or not) and last date if there are a child present like this:

c.name		s.date
Bush		03/03/2003
Nicholson
Jameson	02/01/2003
More		07/06/2002

Mohammad

Best regards

Yngve                          Received on Fri Sep 05 2003 - 12:45:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US