December 10, 2008 at 9:16 pm
is there any other BETTER way to write the following query??
SELECT
T_1.COLUMN_1
, T_1.COLUMN_2
, T_1.COLUMN_3
, SUM(T_1.COLUMN_4)
FROM TABLE_1 T_1WHERE NOT EXISTS(SELECT T_2.COLUMN_1 FROM TABLE_2 T_2WHERE T_1.COLUMN_1 = T_2.COLUMN_1 )
AND T_1.COLUMN_1 != 'None'
GROUP BY T_1.COLUMN_1, T_1.COLUMN_2, T_1.COLUMN_3
i dont want to use subquery
please help
December 11, 2008 at 12:25 am
mohd.imtiaz (12/10/2008)
i dont want to use subquery
Why not?
Is the query too slow? It is using excessive resources? Causing blocking?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 11, 2008 at 6:51 am
If you check out this thread you'll see that method you are using is the consensus pick for best performing.
Of course as Gail asked, why do you want to avoid the subquery?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 11, 2008 at 11:38 pm
Its a correlated sub query, and i have gone through may site which says corelated syb queries work very slow.
is tht true??
guide me
December 12, 2008 at 12:27 am
mohd.imtiaz (12/11/2008)
Its a correlated sub query, and i have gone through may site which says corelated syb queries work very slow.is tht true??
In most cases (including this one) no. The optimiser is perfectly capable of handling most correlated queries in an efficient manner.
The one time where correlated subqueries are slow is when the comparison with the outer query is an inequality
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply