다음 저장 프로 시저를 고려하십시오.
alter procedure getRisks @id int, @convertedRiskValue int
as
select top 1 table1.id, idRisk, riskValue from table1
left join table2
on table1.id = table2.id
where table1.id= @id
order by table2.id desc
idRisk
값은 항상 1-4에서 다양하고는 riskValue
0-1000에서 달라질 수 있습니다.
내가 뭘하고 싶어?
riskValue
에 idRisk
다음과 같이 "유형"을 입력 @convertedRiskValue
하고 select 문에서 반환합니다.
어떤 아이디어?
이 시도 :
alter procedure getRisks @id int, @convertedRiskValue int
as
select top 1 table1.id, CASE WHEN RiskValue >= 0 AND RiskValue <= 250 THEN 1
WHEN RiskValue >= 251 and RiskValue <= 500 THEN 2
WHEN RiskValue >= 501 and RiskValue <= 750 THEN 3
WHEN RiskValue >= 751 and RiskValue <= 1000 THEN 4 end as idRiskType
, riskValue from table1
left join table2
on table1.id = table2.id
where table1.id= @id
order by table2.id desc
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다