gpt4 book ai didi

db2 - 如何在多列上选择不同的计数?

转载 作者:行者123 更新时间:2023-12-04 21:10:11 26 4
gpt4 key购买 nike

如何在多列上选择不同的计数?

SELECT COUNT(DISTINCT col1, col2, col3) FROM table; 

在 DB2 中是否有与此等效的工作?

最佳答案

有多种选择:

select count(*) from
(select distinct col1, col2, col3 FROM table) t
另一种方法是通过 CONCAT 组合列:
select count(distinct col1 || col2 || col3) from table
第一个选项是更干净(并且可能更快)的选项。

关于db2 - 如何在多列上选择不同的计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48167968/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com