Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Table Join
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00669751
Message ID:
00669856
Vues:
13
What happens if you reorder the tables:
FROM 
	holding thold 
	left outer join holding yhold on (thold.portid = yhold.portid and thold.securityid = yhold.securityid) 
	inner join security on thold.securityid = security.securityid 
	inner join portfolio on thold.portid = portfolio.portid 
WHERE 
	thold.date = @asofdate 
	and yhold.date = @prevdate
You'll still have to make Sergey's first suggestion and allow a NULL value for yhold.date.

-Mike

>Hi,
>
>I'm trying to join a table onto itself based on a join of two fields (see below the FROM and WHERE clauses). The third join "left join holding yhold..." is joining the holding table onto the holding table based on two fields the portid and securityid. The result I am receiving is only the matching records even though I have specified left join. What I want is all the records from thold and any matching from yhold.
>
>Is what I am attempting to do permissable? If so any suggestions would be appreciate.
>
>
>FROM holding thold join security on thold.securityid = security.securityid
> join portfolio on thold.portid = portfolio.portid
> left join holding yhold on (thold.portid = yhold.portid and thold.securityid = yhold.securityid)
>WHERE thold.date = @asofdate and yhold.date = @prevdate
>
>Thanks
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform