Advertisement

09.26.2006 at 06:59AM PDT, ID: 22002976
[x]
Attachment Details

Select bottom?

Asked by skbohler in MS SQL Server

Tags: ,

Hello,

I have a query and I want to retrieve the last 10 rows instead of the first 10 rows.

I know that the typical way is to just switch the order that you sort on.

But, I need the bottom 10 rows in a certain order.

Basic query is:

SELECT MAX(RecordID), Description, URL
FROM tblActivity
where UserID = X
Group by Description, URL
Order BY RecordID

This shows all of the rows in tblActivity for user X (with duplicates removed using MAX)

But, I only want to see the 10 most recent results in order from earliest to latest.

If I change it to "Select TOP 10..." and "Order By RecordID DESC", then I cut it to 10 rows, BUT the order goes from top to bottom, which I don't want.

Any thoughts?

Thanks in advance,

Steve

Start Free Trial
[+][-]09.26.2006 at 07:01AM PDT, ID: 17601255

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: bottom, select
Sign Up Now!
Solution Provided By: Mr_Peerapol
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32