|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 4:04 AM
Points: 127,
Visits: 307
|
|
Dear All I have a problem, I have data like this
ID Product Product_code Status 19 EAI ZBC82 Active 19 EAI Z23V7 Inactive 16 DP 13598940 Active
Now I want to select record in this format for check whether all such DP Product code id have any Active trading code in same id.
Client ID Trading_Code Status 13598940 ZBC82 Active
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 11:35 AM
Points: 11,646,
Visits: 27,750
|
|
in general, you'll see two ways to do this.
you can use a SELECT * FROM TABLE1 WHERE [Client ID] in (SELECT [Client ID] FROM TABLE2 WHERE Trading_Code IN('ZBwhatever') )
or you can left outer join the table
SELECT * FROM TABLE1 LEFT OUTER JOIN TABLE2 ON TABLE1.[Client ID]=TABLE1.[Client ID] WHERE WHERE TABLE2 .Trading_Code IN('ZBwhatever')
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|