Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last 5 records from non sequential recordset

Status
Not open for further replies.

mike1955

Programmer
Jul 21, 2005
32
0
0
GB
using a command sql function to create subroutine to populate the report. Pulling from a large table within an oracle dbase with many different record types. PK is sample_number but select criteria is on something else. Recordset comes from throughout the table and is not sequential in its entry.

Want the last five entries

Tried
select sample_number from sample
where description = 'WiTower6'
order by sample_number desc
limit 5

but it does not like the code

anyone help with this method or perhaps a better way please?

Regards
Mike
 
How are you connecting to Oracle? If ODBC, use the Crystal supplied ODBC, or better yet, use Oracle native connectivity, but don't use the Oracle supplied ODBC driver.

What version of Crystal?

Anyway, I've never heard of a LIMIT 5 before.

Try:

select sample_number from sample
where description = 'WiTower6'
and rownum < 6
order by sample_number desc

-k
 
Yanno, since you're using a sorted order you might need:

select e.sample_number
from
(select sample_number from sample
where description = 'WiTower6'
order by sample_number desc) e
WHERE ROWNUM < 5

-k
 
connecting via ODBC supplied by oracle (orahome92) and V9 crystal. Testing on an extracted access version of the dbase, it's ODBC and microsoft driver. Have to do this unfortunately and adjust for the sql differences when going back to live dbase.

Answers did not work (too few parameters)but has reminded me of the way to do it. Will sort from here.....

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top