Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery syntax
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01615658
Message ID:
01615677
Vues:
30
>Sorry I am not clear. Let me clarify. Table2 could have many records with the field ID_FIELD matching the ID_FIELD in the Table1. I want ONLY those that have entry 'ABC' in field FIELD2 to be considered. That is, if the entry in FIELD2 is '123' do not even consider it. But if the entry in the FIELD2 is 'ABC' (FIELD2 = 'ABC') consider it. But if it was created today (that is, DATE_FLD is equal to the current date - today), exclude it.
select T1.* from Table1 T1 where exists (select 1 from Table2 T2 where T2.IdField = T1.IDField and T2.Field2 = 'ABC')
and not exists (select 1 from Table2 T3 
where T3.IdField = T1.IdField and CAST(T3.dateField as date) = CAST(CURRENT_TIMESTAMP as DATE))
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