db2 - Identify international orders from domestic
问题描述
I am trying to distinguish domestic customers from international customers. I can do it in SQL but I need to do it in DB2. In SQL I would say.
Select
DCSCRY,
case when ocrh.dcscry = ' ' then 'BLANK' else case when ocrh.dcscry <> 'US ' then 'Y' else '' end
end as INTER
from ocrh
Result
DCSCRY INTER
US
US
CA Y
CA Y
Any advice in DB2?
解决方案
I don't think the SQL you've shown is valid anywhere...nor does it match the results you've shown...
when ocrh.dcscry = ' ' then 'BLANK'
But your results don't show the string BLANK
DCSCRY INTER
In any event you've got an extra else
and case
in the statement you've posted. The correct syntax is
case
when
when
else
end
So your statement should be
Select
DCSCRY,
case
when ocrh.dcscry = ' ' then 'BLANK'
when ocrh.dcscry <> 'US ' then 'Y'
else ''
end as INTER
from ocrh
推荐阅读
- html - 如何在 HTML 中创建具有两种不同样式的列表?
- angular7 - 如何在angular7中动态添加Dom元素
- perforce - Perforce 文件不在客户端视图中
- excel - 包含选定/活动单元格的 VBA 图表标题
- python-3.x - 熊猫阅读 excel 并用删除线跳过单元格
- flutter - Flutter:Listview Builder水平内部堆栈小部件
- java - org.springframework.data.domain.PageImpl 无法反序列化,当我想使用带有注释@Cacheable(spring cache)的findAll(Pageable pageable)时?
- node.js - 使用 express 路由器时无法读取 express 中未定义的属性“get”
- c - 为什么将结构放在没有参考名称的结构中
- java - Java 中是否有接受多个引号字符的 CSVReader 类?