Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Subquery help with Max !
I have a table like this:
Paymentkey PaymentYear PaymentMonth
1 2001 1 1 2000 2 1 2000 6 1 2002 12 2 2003 1 2 2004 6 3 2002 3
I want to retrieve the lowest PaymentYear AND PaymentMonth for a particular PaymentKey. For example, Paymentkey1 should return PaymentYear(2000),PaymentMonth(2).
Seems simple but I can't seem to get it to work. I have tried this (among other things!):
SELECT c.PaymentYear, a.PaymentMonth
FROM tblPaymentschedule a
WHERE a.paymentmonth = (Select Max(PaymentMonth) from
tblPaymentSchedule b where b.paymentkey = '1'
AND b.paymentyear = (Select Max(PaymentYear) from tblPaymentSchedule c
where c.paymentkey = '1'))
How can I get this to work?!
Thanks very much for your help,
April
Received on Mon Feb 25 2002 - 17:20:12 CST