在我的查询中,我有一个case语句,如果条件匹配,我想将列转换为字符串值。另外,我想知道case语句结果的重复值的总数。例如:
select NULL as column_1,
CASE WHEN name IS NOT NULL THEN CAST(name as string)
ELSE '0' END as column_2,
(select COUNT (cast(column_2 as string)) from input_table
group by (cast(column_2 as string)) HAVING count(cast(column_2 as string)) > 1) as column_3
from input_table
我可以同时计算case语句和条件输出吗?有什么建议吗?
1条答案
按热度按时间kkbh8khc1#
我会用cte。不是100%清楚你在找什么,但试试这个。