Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Second highest value
<raorg_at_my-deja.com> wrote in message news:7ofdda$m8j$1_at_nnrp1.deja.com...
> Hi all,
> I have a view:
> dealid,
> customerid,
> accountid,
> invoicedate,
> invoicenum,
>
> For group of dealid, customerid, accountid, How can I get the max
> invoicedate and the second highest invoice date value. preferably in
> one query, but two will definitely help.
select a.invoicedate
from view_name a, view_name b
where a.invoicedate<=b.invoicedate
group by a.sal
having count(distinct b.invoicedate)<=2;
Received on Tue Aug 10 1999 - 03:33:11 CDT
![]() |
![]() |