Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Assigning categories to values 1 Expand / Collapse
Author
Message
Posted Monday, May 13, 2013 9:48 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:44 AM
Points: 7,648, Visits: 10,636
Comments posted to this topic are about the item Assigning categories to values 1


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1452389
Posted Monday, May 13, 2013 9:49 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, January 20, 2016 3:52 PM
Points: 1,818, Visits: 836
Ouch - interesting question thank you

Hope this helps...

Ford Fairlane
Rock and Roll Detective





Post #1452390
Posted Monday, May 13, 2013 10:31 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:15 PM
Points: 197, Visits: 460
Nice one. Would have had it wrong if I hadn't expected a "catch".
Post #1452393
Posted Monday, May 13, 2013 10:51 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, April 5, 2016 5:24 AM
Points: 644, Visits: 234
Simple and interesting one. Got it right.. Thanks....
Post #1452394
Posted Monday, May 13, 2013 11:05 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, May 11, 2016 7:35 AM
Points: 1,378, Visits: 1,579
Lucky enough to find the anomaly instead of getting into the trap of "BETWEEN (high) AND (low)" which should be otherwise

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1452396
Posted Tuesday, May 14, 2013 12:20 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, July 23, 2015 2:40 AM
Points: 1,242, Visits: 1,549
Good one Hugo.



Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com

Post #1452401
Posted Tuesday, May 14, 2013 12:37 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, May 23, 2016 5:31 AM
Points: 3,615, Visits: 2,774
This was simpy amazing. Simple question yet interesting. It looked plain and simple at first but was just curious to find what was fishy and then i concentrated on the very part.

Nice tricky question.
Post #1452402
Posted Tuesday, May 14, 2013 1:51 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 1,496, Visits: 2,822
Really Good one, Hugo, thank you for posting (so basic and so much of valuable point)

(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 .... )

SELECT KeyCol, ValueCol, CASE
WHEN ValueCol < -10 THEN 'Very negative'
WHEN ValueCol BETWEEN -10 AND -1 THEN 'Bit negative'
WHEN ValueCol = 0 THEN 'Zero'
WHEN ValueCol BETWEEN 1 AND 10 THEN 'Bit positive'
ELSE 'Very positive'
END AS Category
FROM
(
SELECT 1 [KeyCol], 0 [ValueCol]
UNION ALL
SELECT 2, 4
UNION ALL
SELECT 3, -15
UNION ALL
SELECT 4, 14
UNION ALL
SELECT 5, -2
) A
ORDER BY 2



ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
Post #1452419
Posted Tuesday, May 14, 2013 1:51 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:01 AM
Points: 5,121, Visits: 6,841
This was a good question, Hugo
Thanks


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1452420
Posted Tuesday, May 14, 2013 2:45 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, June 20, 2016 6:29 AM
Points: 645, Visits: 530
Liked that one, looked innocuous at first then had a think about it and had a facepalm moment as I was writing out what I thought the results would be and got on the BETWEEN statement! Great question, glad I took some time over it.


MCITP
MCTS - E-Business Card
Twitter: WWDMark

Try not! Do or do not, there is no try

email: info@weekendwebdesign.co.uk
Personal Website: www.markallen-online.co.uk
Business Website: www.weekendwebdesign.co.uk
Post #1452433
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse