Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
geckolumo
Starting Member
1 Post |
Posted - 2005-09-20 : 02:02:34
|
| all, (or anyone for that matter...)I am a little stumped when it comes to attempting the following:What I need is one select statment that selects the top 5 records for each group. i.e. I would like the top 5 stores per region for the following query:select Store_id, Store, Region, [% Chg Cap],[% Chg Rad]from Performance_Variancewhere [% chg RAD]< 0 and Month_end = '2005-09-14 23:59:59'and Level = 'store'Order by Region, Store_idAny help on this is greatly appreciated!txgex |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-09-20 : 03:03:22
|
| will this work?select top 5 fields...from table group by region--------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-20 : 03:11:19
|
quote: Originally posted by jen will this work?select top 5 fields...from table group by region--------------------keeping it simple...
NoIt will select only top 5 records of the first group and not top 5 of each group MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|