现在我的数据表就像
uid mid ..
1 xx ..
2 xx ..
- a ..
- b ..
...
我写了两个 SQL 查询:
select count(distinct uid) from T where uid!='-'
和 select count(distinc mid) from T where uid='-'
,现在我只想在一个 SQL 查询中获得这两个值的总和。有人有任何想法可以帮助我吗?
最佳答案
试试这个查询
select count(distinct uid) from T where uid!='-'
union all
select count(distinc mid) from T where uid='-'
关于sql - 如何在SQL中添加统计值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31108149/