select top 5 * from emp order by newid()

my question is , how this query get executed?

Answers were Sorted based on User's Feedback



select top 5 * from emp order by newid() my question is , how this query get executed?..

Answer / kb

Random 5 rows are selected when newid() is used.

Is This Answer Correct ?    12 Yes 0 No

select top 5 * from emp order by newid() my question is , how this query get executed?..

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

select top 5 * from emp order by newid() my question is , how this query get executed?..

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

select top 5 * from emp order by newid() my question is , how this query get executed?..

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

select top 5 * from emp order by newid() my question is , how this query get executed?..

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

Post New Answer

More SQL Server Interview Questions

What is store procedure? When do you use?

0 Answers  


What is The Use Of TIMESTAMP DataType in SQL Server 2005?

6 Answers  


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.

7 Answers  


Why should one not prefix user stored procedures with ‘sp_’?

0 Answers  


Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

0 Answers  






Explain boyce and codd normal form(bcnf)?

0 Answers  


what is a correlated sub-query? : Sql server database administration

0 Answers  


How does clustered and non clustered index work?

0 Answers  


Explain features and concepts of analysis services?

0 Answers  


What value could be assigned to Varchar Type?

3 Answers  


What is a derived table?

0 Answers  


which one will take 1st priority in case of insert statement and select statement???

2 Answers   HCL,


Categories