Groups | Blog | Home
all groups > sql server (alternate) > july 2003 >

sql server (alternate) : ms access query help


SkunkDave
7/21/2003 9:02:28 PM
I have a table that has numerical ID.

I want a query that will get the 20 highest IDs. So in other words the
query would return the last 20 results entered.

What would even be better is if they were distinct entries by another
column, but it still returned 20 results.

Can you specify in SQL how many results you want?

Thanks
Dave
Oscar Santiesteban Jr.
7/22/2003 12:51:05 AM
You can try the follwing, this is Transact SQL, don't know if it will work
in MS Access.

Select top 20 from yourtable
order by invoice_no desc

This will get you the highest invoice numbers
Hope this is what you want.

Oscar...

[quoted text, click to view]

WKC
7/22/2003 6:48:46 AM
Well Dave, It's actually quite simple. All you would have to do is this:

select top 20 * from [the table name] order by [the ID column] desc

The reason you want to order by DESC b/c it list the column from the highest
numbers to the lowest. So, you'll get the top 20 highest records.

Wei

[quoted text, click to view]

AddThis Social Bookmark Button