I think you may have it reversed.  Work from the inside out.
The "sub select" (or inner select) pulls back *every* row where dateadded > sysdate-7 (by the way shouldn't you use "dateadded >=sysdate-7"?)
Then the outer select simply returns the first three rows from that.


Jason Gulledge.

-----Original Message-----
From: Daniel Kessler [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 06, 2004 2:51 PM
To: CF-Talk
Subject: add a column in oracle

Ah great thanks.  I learned alot.
So, let me re-iterate a bit.
- The first select is the general search where I'm selecting 3 from
the total and I list the columns that I want.  I want all of them,
but it's still better to directly list them both for readability and
accuracy.
- The second select is pulled out of the first select's returns and
it returns them ordered and such.
Or do I have this reversed mentally?
- I like the <= 3 for too.
- Nice to know about the sysdate.  I remembered that there was
something like it the last time I used Oracle but had forgotten.
Nice a clean to read.

I learned alot, thanks.

>SELECT mycolumn1,
>mycolumn2
>FROM (
>   SELECT mycolumn1,
>     mycolumn2
>   FROM whats_new
>   WHERE dateAdded > sysdate-7
>   ORDER BY dateAdded DESC
>)
>WHERE rownum <= 3
>

--
Daniel Kessler

Department of Public and Community Health
University of Maryland
Suite 2387 Valley Drive
College Park, MD  20742-2611
301-405-2545 Phone
www.phi.umd.edu
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to