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

Home -> Community -> Usenet -> c.d.o.server -> Subquery help with Max !

Subquery help with Max !

From: April <privateBenjamin_at_hushmail.com>
Date: 25 Feb 2002 15:20:12 -0800
Message-ID: <6effef59.0202251520.661b1894@posting.google.com>


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

Original text of this message

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