在sql server中需要帮助的人。
我有一个表,里面有国家名称,例如,我有国家“韩国”的数据,比如
韩国
韩国
韩国东南部
韩国西南部
中韩
现在我只需要“韩国”的所有上述国家。这些国家是指单个国家,当多维数据集被浏览时,所有这些国家的销售额都被打破了,在DSV中,我使用了命名查询,因此我想在SQL查询中实现一些东西。这可以做到吗?周围的任何工作都将是有帮助的。
发布于 2016-04-04 14:53:34
您可以使用映射表或如下所示的查询
select
case when country in
(
'Korea'
'South Korea'
'Korea South East'
'Korea South West'
'Central Korea'
) then 'Korea' else country end
as country, sum(amount) as amount
from table
group by
case when country in
(
'Korea'
'South Korea'
'Korea South East'
'Korea South West'
'Central Korea'
) then 'Korea' else country end https://stackoverflow.com/questions/36395827
复制相似问题