|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
case problem
I am using a case statement to compare results between tables and then allocate points based on a match. I am having a problems with radio buttons as I would like to allocate points based on the value selected in the radio button which has a value between 1-5.
e.g if table A, a customer has selected any state and in table B the rating for any state is 4 I would like to multiply 4 by 10 and then allocate the points, if no state was selected then they get 0. ,(CASE WHEN C.LocationState = P.PState THEN 20 ELSE 0 END +CASE WHEN CLocationState = P.mstate THEN 50 ELSE 0 END +CASE WHEN C.LocationState = p.StateBirth THEN 10 ELSE 0 END) AS geography ,(CASE WHEN c.salaryto = p.SalaryMin THEN 20 ELSE 0 END +CASE WHEN c.salaryfrom = p.SalaryExp THEN 40 ELSE 0 END) AS salary ,(CASE WHEN c.BoardStatus = p.pBoardStatus THEN 40 ELSE 0 END This is the problem is not sure how to add the code that will allow a comparison of an int and a varchr and then give the points. +(CASE cl.AMG ='1' AND p.state IS NOT NULL THEN 1 X 10 ELSE 0 END +(CASE cl.AMG ='2' AND p.state IS NOT NULL THEN 2 X 10 ELSE 0 END +(CASE cl.AMG ='3' AND p.state IS NOT NULL THEN 3 X 10 ELSE 0 END +(CASE cl.AMG ='4' AND p.state IS NOT NULL THEN 4 X 10 ELSE 0 END +(CASE cl.AMG ='5' AND p.state IS NOT NULL THEN 5 X 10 ELSE 0 END) AS qualifi Thanks in advance |
|
#2
|
|||
|
|||
|
Just out of curiosity, why dont' you structure your CASE statements like this:
Code:
CASE C.LocationState WHEN P.PState THEN 20 WHEN P.mstate THEN 10 WHEN p.StateBirth THEN 50 ELSE 0 END AS 'geography' or even like this: Code:
CASE WHEN (cl.AMG ='1' AND p.state IS NOT NULL) THEN 10 WHEN (cl.AMG ='2' AND p.state IS NOT NULL) THEN 20 .. ELSE 0 END AS 'qualify'
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > case problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|