有PRODUCT表, 有
Id, name , coutry, state 字段
我要查找PRODUCT表, 如果country字段的值为‘cn’,’tw’
就查出state字段, 如果是其他的值就查出country字段,
为空就不输出, 怎么写这条sql语句
Id, name , coutry, state 字段
我要查找PRODUCT表, 如果country字段的值为‘cn’,’tw’
就查出state字段, 如果是其他的值就查出country字段,
为空就不输出, 怎么写这条sql语句
e varchar2(2));表已创建。SQL> select case
2 when country='cn' then state
3 when country='tw' then state
4 when country is null then null
5 else country
6 end result
7 from product;未选定行SQL>