0

Oracle SQL devに変換しようとしているアクセスクエリがあります。IIf(vw_gdp_currentqry.LOC='0300','F','P') AS SRCE でエラーが発生しているようです 。 誰か助けてください

SELECT
vw_gdp_currentqry.YEAR, 
vw_gdp_currentqry.LOC, 
**IIf(vw_gdp_currentqry.LOC='0300','F','P') AS SRCE,** 
vw_gdp_currentqry.METHOD, 
vw_gdp_currentqry.current_value
FROM vw_gdp_currentqry
WHERE vw_gdp_currentqry.IND)='TOT';
4

2 に答える 2

3

トライdecode機能

SELECT
vw_gdp_currentqry.YEAR, 
vw_gdp_currentqry.LOC, 
decode (vw_gdp_currentqry.LOC,'0300', 'F', 'P' ) AS SRCE,
vw_gdp_currentqry.METHOD, 
vw_gdp_currentqry.current_value
FROM vw_gdp_currentqry
WHERE vw_gdp_currentqry.IND='TOT';

またはcase構文で

SELECT
vw_gdp_currentqry.YEAR,             
vw_gdp_currentqry.LOC, 
case vw_gdp_currentqry.LOC
  when '0300' then 'F'
  else 'P' 
end AS SRCE,
vw_gdp_currentqry.METHOD, 
vw_gdp_currentqry.current_value
FROM vw_gdp_currentqry
WHERE vw_gdp_currentqry.IND='TOT';

詳しくは

于 2013-07-26T17:54:38.630 に答える
0

と を組み合わせてNULLIF使用NVL2​​できます。

の場合にのみ、この組み合わせを使用できます。あなたの場合は次のとおりですvw_gdp_currentqry.LOCNOT NULL

SELECT
vw_gdp_currentqry.YEAR, 
vw_gdp_currentqry.LOC, 
nvl2(nullif(vw_gdp_currentqry.LOC,'0300'),'P','F'),
vw_gdp_currentqry.METHOD, 
vw_gdp_currentqry.current_value
FROM vw_gdp_currentqry
WHERE vw_gdp_currentqry.IND='TOT';
于 2017-04-24T09:04:56.923 に答える