SQLTeam.com | Weblogs | Forums

Top 5 rows returned individually


#1

Hello,

I have a table containing manufacturing data. I need to return the top 5 rows like -

ItemNo Total
8745-DS-M 1230
55004-LFT-XL 560
8743-DS-M 520
55004-RT-XL 486
8744-FG-XS 444

That was accomplished. Now, I need to create an overview screen, a dashboard where I will use each of the rows returned individually to show graphical content.

I need to be able to pull each of th above 5 rows individually in 5 different containers on my screen. How will I reference each row individually.

8745-DS-M 55004-LFT-XL 8743-DS-M 55004-RT-XL 8744-FG-XS
1230 560 520 486 444

I only need the SQL to reference the rows individually in different containers in my screen.

Update -
The table is dynamic, so the items can be random and different everyday.

Thanks,

Mohit.


#2

does the table have an id column of some sort? If not, can't you just query based on the item number? (you might want to index that column if it isn't already)


#3

Nope !.This is a production environment and I can't make changes.


#4

You can use ROW_NUMBER() to add a unique number from 1 to 5 for every returned.


#5

Can you query by item number?