Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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 @ 1:37 PM
Points: 6,007, Visits: 8,270
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, September 17, 2014 6:56 PM
Points: 1,727, Visits: 760
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: Tuesday, May 27, 2014 7:17 PM
Points: 197, Visits: 459
Nice one. Would have had it wrong if I hadn't expected a "catch".
Post #1452393
Posted Monday, May 13, 2013 10:51 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, September 18, 2014 2:30 AM
Points: 595, Visits: 219
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: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
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, February 6, 2014 4:15 AM
Points: 1,242, Visits: 1,546
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: Thursday, September 4, 2014 7:40 AM
Points: 3,545, Visits: 2,652
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


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:24 AM
Points: 962, Visits: 2,190
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


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: Today @ 8:45 AM
Points: 3,969, Visits: 5,212
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, September 1, 2014 7:39 AM
Points: 642, Visits: 520
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