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

Multiple Top 5 Queries In One Query

Status
Not open for further replies.

stoynov

Technical User
Jul 24, 2000
4
0
0
US
How can I take a query with the following fields and data:

NameParent Name Amount Month(YYYYMM) Amount2
XYZ A 100 200112 1
XYZ B 122 200112 123
XYZ C 34 200112 2
XYZ D 5 200112 2435
XYZ E 5 200112 344
XYZ L 5 200112 34
XYZ F 5 200110 34
ABC H 12 200112 33
ABC V 1222 200112 456
.
.
.

And yield *one* query that will output only the top 5 by Amount for each NameParent (assume >10 different name parents) for each month that the data is available. Assuming that Amount's for a given month are the same so as not to yield Top 6 then what we will do is take the highest of Amount2 to rank by for the Top 5. I think this will require a function of some sort? Any suggestions? The reason why all in one query is so to eventually do a Top5 Amount sum per month per NameParent and plot in graph over time.

Thank You,

Michael
mstoynov@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top