回答

收藏

在SQL在多列中计算不同的值对

技术问答 技术问答 234 人阅读 | 0 人回复 | 2023-09-14

哪个查询将计算行数,但由三个参数区分?
* V! K. W4 m, \( l例子:
& x- _  Q% f0 ]/ qId      Name        Address ==============================1     MyName        MyAddress2     MySecondName  Address2就像是:, b1 S8 b) T# ?
select count(distinct id,name,address) from mytable               
, V. w5 f& _6 x1 X6 [, }- J    解决方案:                                                                . i" k) b, g$ E( a
                                                                要获得的唯一组合数的计数id,name并且address:  R$ s5 `, s$ P! W* J
SELECT Count(*)FROM   (       SELECT DISTINCT               id   name   address        FROM   your_table       ) As distinctified
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则