SQL subquery question

From: Albert Yu <ayu_at_bnr.ca>
Date: 1996/05/16
Message-ID: <319B4FFF.230B_at_bnr.ca>#1/1


I am having a problem with using SQL subquery. What I want to do is the following: Given a table of customers and a related
table of purchase orders, I want to find every customer's latest purchase order by date and time. So what I have now in my subquery is:

select * from tableCustomer x where
time = (select max(time) from tablePO y where x.customer=  y.customer and y.run_date= (select max(date) from tablePO z where y.customer= z.customer group by customer) group by x.customer)

I am not sure if I made an error in the sql statement because I am not getting
all the latest entries coming out.

Or might there be a better way of doing this query.

Thanks in advance,

-- 
Albert Yu               NORTEL			
EMAIL: ayu_at_nortel.ca
Received on Thu May 16 1996 - 00:00:00 CEST

Original text of this message