January 28, 2015 at 10:14 pm
Thanks for question Steve.Never used this function so learnt new funtion 🙂
--rhythmk
------------------------------------------------------------------
To post your question use below link
https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
🙂
January 28, 2015 at 11:55 pm
Thank you for the post, Steve, very good one.
At first, I marked the"1" choice, but didn't feel it right, then thought it will be true for all rows as the comparison was been made with static string '2014' then changed to "8". 🙂 (I used it once so I vaguely remembered and had to refer msdn to make myself clear)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
January 29, 2015 at 12:48 am
Great question. Aside from exam questions on MS certification, I have never ever encountered this in code and never used it myself.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 29, 2015 at 1:27 am
This was removed by the editor as SPAM
January 29, 2015 at 2:12 am
Are there any circumstances where using SOME would be preferable to the equivalent with EXISTS?
January 29, 2015 at 3:28 am
Never used Some fn b4, thanx for sharing the question & info 🙂
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
January 29, 2015 at 4:01 am
Just encountered it - for the very first time in my career - in the generated query of a BO report.
When you select a parameter for a date (e.g. December 2014) it generated a WHERE clause like this:
WHERE month <= ANY (SELECT month FROM dbo.Calendar WHERE month = '2014-12')
I always wonder what kind of idiots where SQL generators for reporting tools.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 29, 2015 at 5:29 am
Nice QotD Steve!, the next question do it with clause "ANY"
😛
January 29, 2015 at 5:42 am
Great question, and I nearly clicked 0 because '2014' = True SHOULD fail, but doesn't in SQL.
January 29, 2015 at 5:52 am
Good one Steve, I clicked the 1 and was about to submit when my eyes landed on the 500 and the light bulb clicked on..... 500 > 200 and = 2014 means Steve is being sneaky - as usual!
January 29, 2015 at 6:38 am
I've never used it or encountered it either, so I learned something new. Thanks!
January 29, 2015 at 7:10 am
Good introduction Steve! I've never used the SOME function before.
I think it's also pertinent to point out that the reason all 8 rows returned was because of the use of a literal for the comparison and of course the literal didn't change for all eight rows. Had the literal been replaced with a column reference like this:
SELECT
CustomerID
FROM
sales
WHERE Salesyear = SOME (SELECT salesyear FROM sales WHERE amount > 200);
Then it would have resulted in only four rows returned (for those matching the Salesyear 2014).
I must admit some curiosity along with several others in wondering what benefits this presents over the EXISTS clause.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
January 29, 2015 at 7:43 am
Brian Hibbert (1/29/2015)
Great question, and I nearly clicked 0 because '2014' = True SHOULD fail, but doesn't in SQL.
So this is the real answer. Much better than the provided link in explaining why 8 was the correct answer.
January 29, 2015 at 8:29 am
doug.davidson (1/29/2015)
Brian Hibbert (1/29/2015)
Great question, and I nearly clicked 0 because '2014' = True SHOULD fail, but doesn't in SQL.So this is the real answer. Much better than the provided link in explaining why 8 was the correct answer.
I think I'm not quite understanding what SOME (or Any) actually does.
A quick read of the BOL says the return type is Boolean, but it's not quite as simple as that. SOME isn't a standalone function as I initially thought, it's more like a modifier to the comparison operators.
Viewing 15 posts - 1 through 15 (of 33 total)
You must be logged in to reply to this topic. Login to reply