Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Brain Freeze? or is it possible
Message
De
12/01/2016 18:01:18
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01629732
Message ID:
01629738
Vues:
37
>>Maybe this is the question I should have asked:
>>
>>Table company has a comp_code column - a primary key and a comp_group column
>>comp_group can be blank or it can contain the key to itself or another row in the table.
>>
>>How can I find all the members of the group that @comp_code belongs to?
>
>This is still not very clear. Can you post a sample input and desired output? Are you looking for recursive cte?
DECLARE @comp_code CHAR(4)

SELECT @comp_code = '2287'

SELECT a.* FROM
(SELECT * FROM company WHERE compgroup = (SELECT compgroup FROM company WHERE comp_code = @comp_code)) A
OK.. some head scratching gave me this.
It returns all the members of the group that @comp_code belongs to.

I think that will let me solve the rest of it

Thanks for trying to understand me, Naomi.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform