Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Applying a filter to unioned results
Message
From
27/06/2011 11:12:21
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01516238
Message ID:
01516260
Views:
41
>>>>>>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 ...
>>>>
>>>>Hi Naomi,
>>>>Your response took 2 minutes. I'd appreciate it if you could cut that down to 1 minute in the future. I am a busy person. (JUST KIDDING, thanks for the prompt response!)
>>>
>>>Smart of you to put kidding in upper case as some with big ego will not understand a joke unless you explicitly and unequivocally indicate that you are not serious. This, of course, does not apply to all present in this thread.
>>
>>I try to be very explicit, especially when dealing with potential language barriers.
>
>I know what you mean. Whenever I talk to people from UK I try to use simpler words <g>.

LOL.
Very fitting: http://xkcd.com/386/
Previous
Reply
Map
View

Click here to load this message in the networking platform