Log in  ::  Register  ::  Not logged in

 Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Assigning categories to values 1 Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, May 14, 2013 2:56 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Monday, July 29, 2013 7:03 PM Points: 197, Visits: 457
 Not sure and can't think of why one would use as "BETWEEN -1 AND -10" with "start" as the higher value in any practical case.Depends on where you are coming from: my initial thought, when I first encountered 'BETWEEN', was "I can't think why one would use BETWEEN in any practical case.". BETWEEN suffers from at least two ambiguities until you consult the "official" definition to find out what arbitrary choices have been made to remove them. The first is the issue in question: it would have made just as much sense, if not more, to make the definition symmetrical with respect to the two bounds. Because [1] it would be more work to write down the alternative expression and [2] the keyword AND in all other contexts implies symmetry of the operands, unlike e.g. 'x BETWEEN a TO b'. The second ambiguity is whether BETWEEN includes or excludes the bounds. Intuitively I would make the wrong assumption there as well.So for me it is a bad language feature, well-deserving of at least one Question of the Day.
Post #1452437
 Posted Tuesday, May 14, 2013 4:06 AM
 SSCrazy Group: General Forum Members Last Login: Today @ 1:00 PM Points: 2,304, Visits: 2,020
 Good one.Thanks!IgorMi
Post #1452480
 Posted Tuesday, May 14, 2013 4:33 AM
 SSCommitted Group: General Forum Members Last Login: Today @ 8:00 PM Points: 1,725, Visits: 2,017
 Good question Hugo :) _______________________________________________________________To get quick answer follow this link:http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1452491
 Posted Tuesday, May 14, 2013 4:44 AM
 Mr or Mrs. 500 Group: General Forum Members Last Login: Yesterday @ 3:30 AM Points: 576, Visits: 1,410
 Alex Fekken (5/14/2013)Not sure and can't think of why one would use as "BETWEEN -1 AND -10" with "start" as the higher value in any practical case.Depends on where you are coming from: my initial thought, when I first encountered 'BETWEEN', was "I can't think why one would use BETWEEN in any practical case.". BETWEEN suffers from at least two ambiguities until you consult the "official" definition to find out what arbitrary choices have been made to remove them. The first is the issue in question: it would have made just as much sense, if not more, to make the definition symmetrical with respect to the two bounds. Because [1] it would be more work to write down the alternative expression and [2] the keyword AND in all other contexts implies symmetry of the operands, unlike e.g. 'x BETWEEN a TO b'. The second ambiguity is whether BETWEEN includes or excludes the bounds. Intuitively I would make the wrong assumption there as well.So for me it is a bad language feature, well-deserving of at least one Question of the Day.... even if AND is replaced with TO ... it still works in the same way... and when you know the BETWEEN included the bounds, why you want to use your "intuition" and then make the "wrong assumption"? (I have used this keyword and never thought of going alternate.. and BETWEEN works as it suppose to work)(my concern is with the start expr with the higher value and then put lower value to the end expr and I don't see any practical case where and how it is used to make the code work...) ww; Raghu--There are only 10 types of people in the world, those who understand binary, and those who don't.Note: (as of now) only.. 1 and 4 applies (i am on my way...)
Post #1452494
 Posted Tuesday, May 14, 2013 4:47 AM
 Ten Centuries Group: General Forum Members Last Login: Today @ 5:00 AM Points: 1,221, Visits: 1,290
 Raghavendra Mudugal (5/14/2013)(Not sure and can't think of why one would use as "BETWEEN -1 AND -10" with "start" as the higher value in any practical case. When I saw -1 as the start value.. I thought that might be the catch here and .... )I can think one can copy-paste positive thresholds and write minus signs afterwards. See, understand, learn, try, use efficient© Dr.Plch
Post #1452496
 Posted Tuesday, May 14, 2013 4:49 AM
 Ten Centuries Group: General Forum Members Last Login: Today @ 5:00 AM Points: 1,221, Visits: 1,290
 Nice question, thank you very much for two very valuable points See, understand, learn, try, use efficient© Dr.Plch
Post #1452498
 Posted Tuesday, May 14, 2013 5:00 AM
 Mr or Mrs. 500 Group: General Forum Members Last Login: Yesterday @ 3:30 AM Points: 576, Visits: 1,410
 honza.mf (5/14/2013)Raghavendra Mudugal (5/14/2013)(Not sure and can't think of why one would use as "BETWEEN -1 AND -10" with "start" as the higher value in any practical case. When I saw -1 as the start value.. I thought that might be the catch here and .... )I can think one can copy-paste positive thresholds and write minus signs afterwards.I see you missed the tags ww; Raghu--There are only 10 types of people in the world, those who understand binary, and those who don't.Note: (as of now) only.. 1 and 4 applies (i am on my way...)
Post #1452503
 Posted Tuesday, May 14, 2013 5:02 AM
 Ten Centuries Group: General Forum Members Last Login: Today @ 7:45 AM Points: 1,405, Visits: 1,752
 Nicely posed and explained. I suspected the BETWEEN might cause a problem, but went for the wrong answer anyway.I lost those two very valuable points, delaying my retirement by at least five years. Fortunately I have my mutual funds to fall back on. Please don't go. The drones need you. They look up to you.Connect to me on LinkedIn
Post #1452504
 Posted Tuesday, May 14, 2013 5:38 AM
 SSCommitted Group: General Forum Members Last Login: Today @ 1:50 AM Points: 1,541, Visits: 5,606
 Thomas Abraham (5/14/2013)I lost those two very valuable pointsI hadn't noticed it was two points.Woo hoo - Barbados here I come!
Post #1452518
 Posted Tuesday, May 14, 2013 6:29 AM
 SSC Veteran Group: General Forum Members Last Login: Tuesday, August 13, 2013 11:43 AM Points: 242, Visits: 433
 `declare @test intset @test=-2select case when @test between -1 and -10 then 'Order does not matter' else 'Order matters' end as Conclusion`It would seem to me that order shouldn't matter. As it is, if you are using parameters for the comparison and don't know which will be larger, you would need the below:`select case when (@test >= @compare1 and @test <= @compare2) OR (@test >= @compare2 and @test <= @compare1) then 'Sheesh, what a long way around.' end`I saw it was from Hugo, and checked carefully for tricks. Not carefully enough. Puto me cogitare, ergo puto me esse.I think that I think, therefore I think that I am.
Post #1452532

 Permissions

 Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.