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 |
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-12 : 01:35:43
|
Hello,Example data.col col1 col21 a type10 u type22 t type15 k type23 y type14 b type1I want to return the "2 t type1" in my query.Select top 1 * from (Select top 2 * from table where col2 = type1) AliasTable Order by col descWhen I ran my query the result is "4 b type1".. Any idea? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-12 : 02:05:41
|
| Select top 1 * from (Select top 2 * from table where col2 = 'type1' order by col) AliasTable Order by col descMadhivananFailing to plan is Planning to fail |
 |
|
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-12 : 02:52:49
|
| wow... ^_^ it worked..may i know what is behind on your query?.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-12 : 04:06:19
|
quote: Originally posted by k_cire0426 wow... ^_^ it worked..may i know what is behind on your query?..
I included order by inside the derived tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|