Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by Hugo Kornelis
»
HAVING EXISTS
37 posts, Page 1 of 4
1
2
3
4
»
»»
HAVING EXISTS
Rate Topic
Display Mode
Topic Options
Author
Message
Hugo Kornelis
Hugo Kornelis
Posted Tuesday, September 07, 2010 10:18 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 5:18 AM
Points: 5,233,
Visits: 7,028
Comments posted to this topic are about the item
HAVING EXISTS
Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis
Post #982025
UMG Developer
UMG Developer
Posted Tuesday, September 07, 2010 10:46 PM
SSCrazy
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
Great question Hugo, thanks!
I wasn't sure if that was allowed or not, so I had to do some research and learned something new. Note that I can imagine where I need to apply it, but you never know. ;)
Post #982036
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Wednesday, September 08, 2010 12:22 AM
Hall of Fame
Group: General Forum Members
Last Login: Today @ 3:48 AM
Points: 3,125,
Visits: 4,311
Thanks for the question.
Learned something
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #982065
Koen Verbeeck
Koen Verbeeck
Posted Wednesday, September 08, 2010 12:35 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 3:23 AM
Points: 9,367,
Visits: 6,464
Great question. I got it wrong, obviously, but I learned something.
How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
Member of
LinkedIn
. My blog at
LessThanDot
.
MCSA SQL Server 2012 - MCSE Business Intelligence
Post #982067
Sree Arjun Div
Sree Arjun Div
Posted Wednesday, September 08, 2010 12:41 AM
SSCrazy
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 3:44 AM
Points: 2,173,
Visits: 1,350
Thanks For Question
I learned Having Exists ...!
Post #982069
hrvoje.piasevoli
hrvoje.piasevoli
Posted Wednesday, September 08, 2010 1:45 AM
Old Hand
Group: General Forum Members
Last Login: Friday, December 07, 2012 9:27 AM
Points: 361,
Visits: 507
Great question! Thank You Sir!
Realy flexible, handy and readable method.
Hrvoje Piasevoli
Post #982090
Nakul Vachhrajani
Nakul Vachhrajani
Posted Wednesday, September 08, 2010 3:40 AM
Ten Centuries
Group: General Forum Members
Last Login: Thursday, May 16, 2013 9:52 AM
Points: 1,277,
Visits: 1,608
Hello!
I believe the most important keys to solving this one (as you rightly mentioned) are to understand that:
1. Both the WHERE & HAVING are "binary" conditions, i.e. they would either evaluate to TRUE (meaning the row/group remains) or FALSE (meaning the row/group is filtered out)
2. The logical processing order evaluates this particular condition by group (i.e. uses the MAX(a.TheValue) for that group)
a. This is because HAVING is evaluated later on (after the GROUP BY)
I knew for sure about# 1, but #2 was a little too much to resist an experiment due to the use of the aggregation. I thus ended up running the query and confirmed my belief.
Thanks & Regards,
Nakul Vachhrajani.
http://beyondrelational.com/modules/2/blogs/77/nakuls-blog.aspx
Be courteous. Drive responsibly.
Follow me on
Twitter:
@nakulv_sql
Google Plus:
+Nakul
Post #982149
Andeavour
Andeavour
Posted Wednesday, September 08, 2010 4:35 AM
SSC Eights!
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 5:34 AM
Points: 981,
Visits: 821
Great question... I was another victim, but I learned something new here today, which hopefully I'll remember
Post #982174
jcrawf02
jcrawf02
Posted Wednesday, September 08, 2010 5:33 AM
SSCrazy
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:36 PM
Points: 2,549,
Visits: 18,880
Definitely a tricky one. Hugo, do you have an application of this?
---------------------------------------------------------
How best to post your question
How to post performance problems
Tally Table:What it is and how it replaces a loop
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
Post #982201
ronmoses
ronmoses
Posted Wednesday, September 08, 2010 5:46 AM
SSChasing Mays
Group: General Forum Members
Last Login: Today @ 5:38 AM
Points: 648,
Visits: 685
I had to stare at it a long while, but I finally came up with the right answer without running any queries or researching... woo-hoo!
Nice question!
ron
-----
a haiku...
NULL is not zero
NULL is not an empty string
NULL is the unknown
Post #982212
« Prev Topic
|
Next Topic »
37 posts, Page 1 of 4
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.