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 |
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-12 : 10:51:18
|
| table t1group order c1 c2 c3 a 8 -----a 6a 4a 4a 4a 7b 1b 7b 2c -----expected resulta 4 ---a 4b 1 ---b 2I want to choose the a row in each group with minimum two order,how can I do that?Thanks |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-11-12 : 11:00:25
|
What is in the 3rd column? What is the actual data and structure of the table?What would prevent the 3rd A 4 record from coming in?Easy to sort out, but best to post some actual data and exact expected results. Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-12 : 13:21:23
|
[code]SELECT d.[Group], d.[Order], d.c1, d.c2, d.c3FROM ( SELECT [Group], [Order], c1, c2, c3, ROW_NUMBER() OVER (PARTITION BY [Group] ORDER BY [Order]) AS RecID FROM t1 ) AS dWHERE d.RecID <= 2[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-11-12 : 13:28:49
|
| THX! |
 |
|
|
|
|
|