We help IT Professionals succeed at work.
Get Started

Using Case or If statement in Select statement, result is a string. Need a number.

k heitz
k heitz asked
on
155 Views
Last Modified: 2017-04-01
Hi Experts;
I have a stored procedure with this case statement in the select query:
(CASE WHEN pae.pitchinzone = 0 AND act.`swungon` = 1 THEN 1 ELSE 0 END) AS Chase,

The stored procedure is called via a pass-thru query in MSAccess.
Problem is the Chase field evaluates to a string and I need it to be numeric.
I've tried cast, convert, +0 on THEN/ELSE values - no success.

I tried switching to an If statement:
cast(if (pae.pitchinzone = 0 and act.swungon = 1,1,0) as unsigned) as chase,
still no success.

The underlying fields are:
pae.pitchinzone is a tinyint, and act.swungon is also an int(11).

I have 3 'formula' fields that are returning strings where I need numbers.

Any advice would be greatly appreciated.
Thanks
Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE