This throws an error:


ORA-00937: not a single-group group function


But it gives me some ideas to work with.


Thanks,
Chris

-----Original Message-----
From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 26, 2004 12:20 PM
To: CF-Talk
Subject: Re: PL/SQL stumper

Lofback, Chris wrote:
> I need to get the first 7 distinct providers in date order with newest first.  Can it be done without "getting fancy"?

> PROVIDER DATESTAMP
> Eckerd Drugs 25-MAY-04
> Walmart 25-MAY-04
> Walgreens 23-MAY-04
> Publix 23-MAY-04
> Hush Puppy Shoes 23-MAY-04
> Publix 22-MAY-04
> Walgreen's 20-MAY-04
> Timmons Drugs 20-MAY-04
> Publix Pharmacy 19-MAY-04
> Walmart 16-MAY-04
> Publix Pharmacy 16-MAY-04
> Publix 14-MAY-04
> Walmart 14-MAY-04
> Publix 14-MAY-04
> Walmart 14-MAY-04

SELECT *
FROM (
SELECT provider,
MAX(datestamp) AS lastDate
FROM table
ORDER BY MAX(datestamp) DESC
) a
WHERE rownum < 8

Jochem
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to