select top 5 * from emp order by newid()
my question is , how this query get executed?
Answers were Sorted based on User's Feedback
Answer / ankita bosamiya
first of all order by clause will be executed that is first
it will be arranged as ascending or descending order and
than first 5 records will be fatched.....
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / anil sharma
newid() function return random row and top 5 return top 5
rows.
So query return top 5 row using random order.
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / sanjeev kumar
newid() used with uniqueidentifier data types in a table
and uniqueidentifier datatype is used to insert randomly
new number, so the above query will give top 5 records in
randomly manner.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / praveen n h
SQL server will execute the query in following way...
Select All top 5 rows which are created in the table from
the time it is created.
reason: newid is the key given to each row regardless of
the values that goes into the row of the table.
For example.
if you have created a table temp
and inserted 10 rows, Only fives rows which are created
first will be listed.
Is This Answer Correct ? | 2 Yes | 6 No |
What is store procedure? When do you use?
What is The Use Of TIMESTAMP DataType in SQL Server 2005?
in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Why should one not prefix user stored procedures with ‘sp_’?
Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?
Explain boyce and codd normal form(bcnf)?
what is a correlated sub-query? : Sql server database administration
How does clustered and non clustered index work?
Explain features and concepts of analysis services?
What value could be assigned to Varchar Type?
What is a derived table?
which one will take 1st priority in case of insert statement and select statement???