Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Having Trouble With a Query
Message
De
17/02/2006 16:06:33
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01097119
Message ID:
01097194
Vues:
20
>You could filter out FK with NULLs easily (if they are the problem).

Yes, I know ... but the second example you gave seemed much simpler, so I went with it. <s> I don't know which one would be faster, but I don't have enough data to benchmark it right now.

Thanks,
~~Bonnie




>Hi Bonnie,
>
>You could filter out FK with NULLs easily (if they are the problem).
>
>SELECT * FROM mytable mt1
>  WHERE mt1.FK IS NOT NULL
>         AND NOT EXISTS ( SELECT * FROM mytable mt2
>                WHERE mt2.FK = mt1.FK and mt2.date > mt1.date)
>
>>Thanks Sergey! The first one didn't work (I assume because of the fact that there can be NULLs in the FK), but the second one worked fine. I needed to tweak it a little more, because I also need to join the second table to further weed out some criteria, but I figured that out easily enough. You gave me a push in the right direction, thanks!!! =)
>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform