oracle: select count(distinct id||adress) form tb;sqlserver: select count(distinct id+adress) form tb;
select count(distinct id,adress) from T
统计单个字段的非重复记录条数: select count(distinct id) from t 统计多个字段的非重复记录条数: SELECT COUNT(*) FROM(select count(distinct id,adress) from t) 统计所有字段的非重复记录条数: select count(distinct *) from t
这样是不行的 会报错 ORA-00909: invalid number of arguments
SQL> select * from t4; ID1 ID2 ---------- ---------- 1 2 1 3 1 2 --查看某一列不同的记录数 SQL> select count(distinct id1) from t4;COUNT(DISTINCTID1) ------------------ 1SQL> select count(distinct id2) from t4;COUNT(DISTINCTID2) ------------------ 2 --查看表中各列不同记录数 SQL> select count(distinct id1||id2) from t4;COUNT(DISTINCTID1||ID2) ----------------------- 2
select count(distinct id||adress) form tb;sqlserver:
select count(distinct id+adress) form tb;
select count(distinct id) from t
统计多个字段的非重复记录条数:
SELECT COUNT(*) FROM(select count(distinct id,adress) from t)
统计所有字段的非重复记录条数:
select count(distinct *) from t
ORA-00909: invalid number of arguments
---------- ----------
1 2
1 3
1 2
--查看某一列不同的记录数
SQL> select count(distinct id1) from t4;COUNT(DISTINCTID1)
------------------
1SQL> select count(distinct id2) from t4;COUNT(DISTINCTID2)
------------------
2
--查看表中各列不同记录数
SQL> select count(distinct id1||id2) from t4;COUNT(DISTINCTID1||ID2)
-----------------------
2