Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
binto
Yak Posting Veteran
59 Posts |
Posted - 2010-05-05 : 09:48:45
|
| I have a select statement.Some part of the statement is given belowSELECT [t0].[ReceivingLocation] From [t0] Where[t0].[ReceivingLocation] IN (SELECT [t0].[ReceivingLocation] FROM [t0] inner join [matrixReceivingLocation] on [matrixReceivingLocation] .[ReceivingCode]= [t0].[ReceivingLocation] inner join (SELECT COUNT([t0].[ReceivingLocation]) as cnt, [matrixReceivingLocation].[ReceivingLocGroup] FROM [t0] inner join [matrixReceivingLocation] on [matrixReceivingLocation].[ReceivingCode]=[t0].[ReceivingLocation] GROUP BY [matrixReceivingLocation].[ReceivingLocGroup] HAVING COUNT ([t0].[ReceivingLocation]) >1) DT ON dt.ReceivingLocGroup= [matrixReceivingLocation].[ReceivingLocGroup]) in this i want to replace the Statement after IN(given as bold), because i have a problem with [t0]'s in the select statement.Also i can't use 'as' after [t0] because [t0] is coming in different name.If any way to replace it to a single select keyword?here after IN we use a Select.I don't know how to solve.Please help.......... Thanks & RegardsBinto Thomas |
|
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2010-05-05 : 10:08:10
|
| The statement inside IN is sufficient to solve your problem so you should remove the part before that statement including IN. |
 |
|
|
binto
Yak Posting Veteran
59 Posts |
Posted - 2010-05-05 : 10:19:26
|
| this is a part of the statement.I have statement before and after this query.So i can't remove IN .Thanks & RegardsBinto Thomas |
 |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2010-05-05 : 10:20:09
|
| [code]SELECT *FROM [t0]WHERE ReceivingLocation IN( SELECT ReceivingCode FROM matrixReceivingLocation WHERE ReceivingLocGroup IN ( SELECT ReceivingLocGroup FROM matrixReceivingLocation GROUP BY ReceivingLocGroup HAVING COUNT(ReceivingLocation) > 1 ))[/code] |
 |
|
|
binto
Yak Posting Veteran
59 Posts |
Posted - 2010-05-05 : 11:01:04
|
| this is not correct.this is very slow ....Thanks & RegardsBinto Thomas |
 |
|
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2010-05-05 : 12:16:44
|
| The outer statement do nothing so you should justify why you need it or else we can't help you |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-05-05 : 12:17:54
|
quote: Originally posted by binto in this i want to replace the Statement after IN(given as bold), because i have a problem with [t0]'s in the select statement.Also i can't use 'as' after [t0] because [t0] is coming in different name.If any way to replace it to a single select keyword?here after IN we use a Select.I don't know how to solve.Please help..........
Can you explain the issue with greater detail? I don't know what you mean by "[t0] is coming in different name." Actually, I'm totaly lost by looking at the code snippet you posted. I know it takes more effort on your part, but if you can help describe the problem in greater detail, we can probably offer better advice without having to make guesses (WAGs). Maybe this link will help:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
|
|
|