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 |
Why do we use trigger?
How to convert numeric expression data types using the cast() function?
In which situation you use Self joins?
1 Answers CarrizalSoft Technologies, HP, TCS,
Simple example for difference between select and cursor in sql
How do I start and stop sql server?
What are the types of resultset?
What are the differences between UNION and JOINS?
3 Answers CarrizalSoft Technologies,
Explain in brief about Microsoft SQL server?
What is the difference between ‘having’ clause and a ‘where’ clause?
I am Having tables T1 and T2 both having same data how to check (or) compare the data in both table are same?
which query u can write to sql server doesn't work inbetween 7.00PM to nextday 9.00AM
What does set rowcount do?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)