Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select items used before a date but not after
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01635849
Message ID:
01635902
Views:
48
>>
>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform