Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select items used before a date but not after
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01635849
Message ID:
01635902
Vues:
46
>>
>>select * from dbo.part_file p where not exists (select 1 from dbo.part_used pu where used_date >='20100101' and pu.part_pk = p.part_pk)
>>and exists (select 1 from dbo.part_used pu where used_date <'20100101' and pu.part_pk = p.part_pk)
>
>Do I understand correctly that you use aliases (e.g. 'p' and 'pu') for readability but the expression can be used without them, correct?

You can write

part_pk = part_file.part_pk

and not use aliases. But you do need to connect the main query with the exists / not exists subquery. I think using aliases is the simplest way to relate the main query and subquery.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform