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 Constraint? How many types of constraints in SQL ?
38 Answers HCL, IBM, NIIT, Wipro,
Where are sql server usernames and passwords stored in the sql server?
Ek lifafa 10 noto se bhara hai usme 2 or 5 ke note nahi hai aur usme total 50Rs hai, to batao lifafe me kon se not kitne hia it’s a challenge thank’s
How many non clustered indexes there can be on table ?
What will be the maximum number of indexes per table?
is there more the two primary key in a single table?
26 Answers Eforce, Systematix,
Can we use Truncate command on a table which is referenced by FOREIGN KEY?
What do you mean by 'normalization'?
0 Answers Ernst Young, Thomson Reuters,
What is logshipping and its purpose?
can a database be shrunk with users active? : Sql server administration
Explain the properties of a relational table?
Where sql server user names and passwords are stored in sql server? : sql server database administration