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 |
|
jerry8989
Starting Member
6 Posts |
Posted - 2008-01-14 : 14:05:37
|
| I have a table that has 5 columns that looks like thisRegion RegionName Row1 Test1 11 Test2 21 Test3 32 Test4 12 Test5 22 Test6 33 Test7 13 Test8 23 Test9 33 Test10 4I need to select the top 2 by Region so I need my result set to beRegion RegionName Row1 Test1 11 Test2 22 Test4 12 Test5 23 Test7 13 Test8 2Thanks |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-01-14 : 14:14:28
|
| if you already have Row column is'nt it a simple ...where row <= 2 |
 |
|
|
jerry8989
Starting Member
6 Posts |
Posted - 2008-01-14 : 14:19:42
|
| I'm sorry I didn't display the data correctly. There might be instances where a specific region only has one row but I still need 2 to come back. The Row column for the blank row is 71 Test1 11 Test2 21 72 Test4 12 Test5 22 72 82 93 Test7 13 Test8 23 Test9 33 Test10 4Sorry if i'm not explaining it good enough |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-01-14 : 14:36:42
|
quote: Originally posted by jerry8989 I'm sorry I didn't display the data correctly. There might be instances where a specific region only has one row but I still need 2 to come back. The Row column for the blank row is 71 Test1 11 Test2 21 72 Test4 12 Test5 22 72 82 93 Test7 13 Test8 23 Test9 33 Test10 4Sorry if i'm not explaining it good enough
>>Sorry if i'm not explaining it good enoughI'm afraid that is true I thought I understood until I saw this: "The Row column for the blank row is 7" ??Rather than have us continue to guess what you want, why don't you try asking again but this time follow the instructions in this link to "set up" your question:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxBe One with the OptimizerTG |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-01-14 : 14:39:11
|
| what do you mean when you say "a specific region only has one row but I still need 2 to come back" |
 |
|
|
jerry8989
Starting Member
6 Posts |
Posted - 2008-01-14 : 15:00:41
|
| I figured it out.Thanks for the help |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-01-14 : 16:11:53
|
| you sure? or people here scared you? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-16 : 02:33:33
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|