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

Home -> Community -> Usenet -> c.d.o.misc -> SQL Help

SQL Help

From: Brent Collins <brent_at_ti.com>
Date: Thu, 15 Apr 1999 12:53:38 -0500
Message-ID: <371627A2.8BD5BBE@ti.com>


I am a novice at SQL and need some help. I have a table that has millions of rows with a Date column. My users would like to select the first or last n rows for a given date range. I can't figure out a good way to do this without returning all rows and use filtering before sending the data back to the client.

I am using Oracle 8.0.4 on Solaris 2.6. I access the data via JDBC using JDK 1.1.6.
I tried using the following SQL statements. select * from table
  where date between start and end

     and rownum < n+1
  order by date asc/desc;
This does not work because the ordering is done after the where clause.

I also tried:
select date, column2, column3 ... etc. from table   where date between start and end

     and rownum < n+1
  group by date;
This works for selecting the first n rows as long as there are no duplicate dates (which is not likely).

Anyone know how I can accomplish this? Please copy my email address when replying.

Any info is appreciated.

--
Brent Collins
SC CIM System Integration
Texas Instruments
brent_at_ti.com
972-997-2679 Received on Thu Apr 15 1999 - 12:53:38 CDT

Original text of this message

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