Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1284
  • Last Modified:

Select Case (greater than number)

hey all, how do i do something like this


num = 12

select case num

    case 10

    case > 10  <-------- greater than????


end select

I read somewhere that you could use the IS keyword, but that didn't work. Any ideas? Thanx

dj
0
engineroom
Asked:
engineroom
  • 3
  • 2
  • 2
  • +2
1 Solution
 
BubbaisBestCommented:
engineroom,

Hopefully someone can give you an exact answer but I never found anything on this when I looked for it.  So what I did was do my If-Then-Else loop and set a variable to a number. I did then did my case.  I know this is a workaround but that was the only thing I could find.

Bubs
0
 
justinbilligCommented:
DECLARE @intNumber INTEGER


SET @intNumber = 12


SELECT
      CASE WHEN
            @intNumber = 12
                  THEN 'Number Equals Twelve'
      WHEN @intNumber < 12
            THEN 'Number Less than Twelve'
      END
0
 
jrramCommented:
You can use a series of if.. else if... statements, but you can't do what you're trying with a CASE statement.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
BubbaisBestCommented:
Here is a snipplet of my code:

If intNum<0 then
   intCase = 1
ElseIf ((intNum>=0) AND (intNum<10)) then
   intCase = 2
ElseIf ((intNum>=10) AND (intNum<100)) then
   intCase = 3
ElseIf intNum >= 100 then
   intCase = 4
End If

Select Case intCase
  Case 1
    ' do here if less than 0
  Case 2
   ' do here between 0 and 10
  Case 3
   ' do here between 10 and 100
  Case 4
   ' do here if over 100
End Select

Bubs
0
 
NeoTeqCommented:
I got creative when seeing the question, and although plenty of alternatives have been offered, it seemed a waste not to post mine:

<%

n = 2

select case true
      case (n = 1)
            %>1<%
      case (n > 1)
            %>2<%
end select

%>
0
 
engineroomAuthor Commented:
neoTeg, is this right?

select case true?
0
 
NeoTeqCommented:
yes... you see, I'm checking if true equals to (n > 1), and if n = 2, then (n > 1) will be true (and true = true so the case is true)
0
 
BubbaisBestCommented:
Excellent NeoTeq...Just what engineroom was needing (as well as myself)...Bubs
0
 
engineroomAuthor Commented:
thanx, that's great!

dj
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now