如何在多个列中选择不重复计数?

Ton*_*nan 3 db2 mainframe

如何选择多个列的不重复计数?

SELECT COUNT(DISTINCT col1, col2, col3) FROM table; 
Run Code Online (Sandbox Code Playgroud)

在DB2中有与之等效的工作吗?

dat*_*rik 7

有多种选择:

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)

第一种选择是清洁器(可能更快)。