sql - 计算红移中不同的多列
问题描述
我正在尝试计算在 Amazon redshift 中有 2 列的不同组合的行。我正在使用的查询是 -
select count(distinct col1, col2)
from schemaname.tablename
where some filters
它向我抛出了这个错误-
亚马逊无效操作:函数计数(字符变化,bigint)不存在`
我尝试投射bigint
,char
但没有奏效。
解决方案
您可以使用子查询和计数
select count(*) from (
select distinct col1, col2
from schemaname.tablename
where some filter
) as t
推荐阅读
- keyboard-shortcuts - 用于在活动拆分视图之间切换的 Konsole 键盘快捷键?
- active-directory - 如何在客户端获取某个 GPO 的安全过滤属性?
- javascript - 如何监听输入中的段值(__/__/___)变化[type="date"]
- mysql - 如何使用 laravel 迁移交换两个索引字段?
- sql - 如何将架构及其所有表传输到新数据库?
- c# - C#/WPF 项目缺少 NuGet DLL 时出现神秘异常?
- amazon-web-services - 如何限制 IAM 用户的 S3 对象最大上传大小为 1 MB?
- r - 如何使用 R 中的循环绘制数据框中的每个变量
- c# - 我只需要显示我插入的多个图像
- java - Tic Tac Toe with swing - X 和 O 的不同颜色