Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Client id which are link to any trading code Expand / Collapse
Author
Message
Posted Tuesday, January 20, 2009 7:18 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, August 9, 2014 2:06 AM
Points: 127, Visits: 355

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

Post #639940
Posted Tuesday, January 20, 2009 8:14 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 11:55 AM
Points: 12,905, Visits: 32,165
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
Post #639961
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse