Can we rewrite subqueries into simple select statements or
with joins? Example?
Answers were Sorted based on User's Feedback
Answer / divya kalra
Subqueries can often be re-written to use a standard outer
join, resulting in faster performance. As we may know, an
outer join uses the plus sign (+) operator to tell the
database to return all non-matching rows with NULL values.
Hence we combine the outer join with a NULL test in the
WHERE clause to reproduce the result set without using a
sub-query.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / syed sajjad
Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query.
| Is This Answer Correct ? | 1 Yes | 0 No |
How to generate random numbers with the rand() function in ms sql server?
What does man by sql wildcard characters in sql server?
What is the command used to check locks in microsoft sql server?
How can I create a plain-text flat file from SQL Server as input to another application?
What is the difference between implicit and explicit transaction?
What is normalization according to you and explain its different levels?
What are recommended options to be used while using db mirroring? : sql server database administration
What are page splits? : SQL Server Architecture
Consider the table T1 it consits A,2,3,4 consider another table t2 it contain 1,2a,3a,4a now i need o get the upadted answer
What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM table
what is IDE,DMV in sql server?
How To Change Column Ordinal Position in SQL Server 2005 using Query i.e I Want To Add Column at Particular Ordinal Position in SQL Server 2005
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)