如何选择多个列的不重复计数?
SELECT COUNT(DISTINCT col1, col2, col3) FROM table;
Run Code Online (Sandbox Code Playgroud)
在DB2中有与之等效的工作吗?
有多种选择:
select count(*) from
(select distinct col1, col2, col3 FROM table)
Run Code Online (Sandbox Code Playgroud)
另一种是通过CONCAT合并列:
select count(distinct col1 || col2 || col3) from table
Run Code Online (Sandbox Code Playgroud)
第一种选择是清洁器(可能更快)。