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 |
|
shiva.ilu2
Starting Member
2 Posts |
Posted - 2010-02-22 : 00:59:32
|
| plz can anyone explan this statement" select TOP 2 1 from table; " |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-02-22 : 01:37:22
|
| The TOP operator will select the specified number of records or specified percentage of the rows from a table.Ex: Select top 5 * from location will Select First 5 records from location table.In your example:select TOP 2 1 from table will return 1 value two times as you are not selecting any column but a static value of 1. |
 |
|
|
shiva.ilu2
Starting Member
2 Posts |
Posted - 2010-02-22 : 02:02:02
|
| ohh thanks a lot pk.. |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-02-22 : 03:30:42
|
| You are welcome..Bohra |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-22 : 03:54:56
|
| Note that TOP without Order by clause is meaningless and data will be returned in random orderMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-22 : 08:44:51
|
quote: Originally posted by madhivanan Note that TOP without Order by clause is meaningless and data will be returned in random orderMadhivananFailing to plan is Planning to fail
In above case it doesnt matter as its just returning the same constant value two timesGenerically what you say makes sense ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-22 : 09:08:30
|
quote: Originally posted by visakh16
quote: Originally posted by madhivanan Note that TOP without Order by clause is meaningless and data will be returned in random orderMadhivananFailing to plan is Planning to fail
In above case it doesnt matter as its just returning the same constant value two timesGenerically what you say makes sense ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Yes My answer was generic MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|