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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top 5 Values By Day 1

Status
Not open for further replies.

gavjb

Technical User
Jul 5, 2005
67
GB
Hi,

I have been asked to create a query which returns the top 5 results by day, I was thinking off doing a top Query and union them all together but the amount of days can be anything between 5 and 30 days.

The Columns I have which I need to query are as follows:

Code:
DATE
FDD
Name
RLD
RLDCS
RLDPS
RBSS

I need the top 5 RLD Entries by Day, does anyone have any idea how I can do this.

Thanks,


Gavin,
 
try this:

SELECT A.DATE, A.FDD, A.Name, A.RLD, A.RLDCS, A.RLDPS, A.RBSS FROM mytable A WHERE A.RLD IN (SELECT TOP 5 B.RLD FROM mytable B WHERE A.DATE=B.DATE ORDER BY B.RLD DESC)

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top