首页 > 解决方案 > 计算红移中不同的多列

问题描述

我正在尝试计算在 Amazon redshift 中有 2 列的不同组合的行。我正在使用的查询是 -

select count(distinct col1, col2)
from schemaname.tablename
where some filters

它向我抛出了这个错误-

亚马逊无效操作:函数计数(字符变化,bigint)不存在`

我尝试投射bigintchar但没有奏效。

标签: sqlamazon-redshift

解决方案


您可以使用子查询和计数

select count(*) from (
  select distinct col1, col2 
 from schemaname.tablename
  where some filter
) as t

推荐阅读