Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Applying a filter to unioned results
Message
 
 
À
27/06/2011 10:42:53
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01516238
Message ID:
01516240
Vues:
62
This message has been marked as the solution to the initial question of the thread.
>I'm having a Monday morning brain fart. In my query, I am performing a union against several tables to return one result set. I'd like to perform a where clause against that entire result set, but I'm not figuring out how to do it.
>
>Something like:
>
>
>SELECT * FROM
>(
>   --Union logic here
>)
>WHERE MyField = @MyFilter
>
Try using derived table (or CTE), e.g.
;with cte as (Here goes UNIONoned query)

select * from cte where ...
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