SAK }‘ŠŮ

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠŮEƒJƒtƒF ˆę—— SAK Streets ŒŸő
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

PostgreSQL •Ň15 - “ÁŽęŠÖ”A‘˝d”ť’čAƒkƒ‹”ť’čAƒkƒ‹”äŠrAcaseAnullif

Ą‘˝d”ť’č

  EOracle ‚Ć“Ż‚ś‚悤‚É case ‚ŞŽg‚Ś‚é‚Ě‚Ĺ”ńí‚É‹­—Í‚Ĺ‚ ‚éB
    ŽAOracle ‚ĹŒž‚¤ decode ‚Í PostgreSQL ‚Ĺ‚Í encode ‚ĆƒZƒbƒg‚Ě•Ę‚Ě
    ŠÖ”‚É‚Č‚Á‚Ä‚˘‚é‚Ě‚Ĺ’ˆÓ‚ˇ‚éB

select key,
  case
    when key = 'a001' then 'aaa'
    when key = 'b002' then 'bbb'
    when key = 'c003' then 'ccc'
    else 'xxx'
  end
  from testm
;

   key    | case
----------+------
 a001     | aaa
 a011     | xxx
 b002     | bbb
 c003     | ccc

select key,
  case key
    when 'a001' then 'aaa'
    when 'b002' then 'bbb'
    when 'c003' then 'ccc'
    else 'xxx'
  end
  from testm
;

select key,
  case key
    when 'a001' then (select b.key from test2m b where b.code1 = a.key)
    when 'b002' then 'bbb'
    when 'c003' then 'ccc'
    else 'xxx'
  end
  from testm a
;

   key    |   case
----------+----------
 a001     | abc01
 a011     | xxx
 b002     | bbb
 c003     | ccc

Ąƒkƒ‹”ť’č

  Ecoalesce() ŠÖ”‚́AĹ‰‚Ě null ‚Ĺ‚Č‚˘ƒf[ƒ^‚đ•Ô‚ˇB

select coalesce(null, 'abc', 'def');

 case
------
 abc

Ąƒkƒ‹”äŠr

  Enullif() ŠÖ”‚́A“™‚ľ‚Ż‚ę‚Î null ‚ށA“™‚ľ‚­‚Č‚Ż‚ę‚΃f[ƒ^1 ‚Ş•Ô‚éB
    ŽŸ‚Ě—á‚́Anull ‚Ş•Ô‚éB

select nullif('abc', 'abc');

 case
------

  EŽŸ‚Ě—á‚́A'abc' ‚Ş•Ô‚éB

select nullif('abc', 'def') ;

 case
------
 abc

ĄPostgreSQL •ŇAJAVA ServletAJSP •ŇŽ‘—ż
ĄMySQL •ŇŽ‘—ż
ĄSQL Šî‘b•ŇŽ‘—ż
ĄSQL Šî‘bŽŔ’n•ŇŽ‘—ż
ĄSQL ƒ`ƒ…[ƒjƒ“ƒO•ŇŽ‘—ż
ĄOracle PL/SQL •ŇŽ‘—ż
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠŮEƒJƒtƒF ˆę—— SAK Streets ŒŸő



Copyright (C) 1999-2017 Y.SAK