例如:表明 T 字段 id adress
最好是能在sql和oracle下通用的句子
谢谢
6 个解决方案
#1
oracle:
select count(distinct id||adress) form tb;
sqlserver:
select count(distinct id+adress) form tb;
select count(distinct id||adress) form tb;
sqlserver:
select count(distinct id+adress) form tb;
#2
select count(distinct id,adress) from T
#3
统计单个字段的非重复记录条数:
select count(distinct id) from t
统计多个字段的非重复记录条数:
SELECT COUNT(*) FROM(select count(distinct id,adress) from t)
统计所有字段的非重复记录条数:
select count(distinct *) from t
select count(distinct id) from t
统计多个字段的非重复记录条数:
SELECT COUNT(*) FROM(select count(distinct id,adress) from t)
统计所有字段的非重复记录条数:
select count(distinct *) from t
#4
一楼经典,巧妙
#5
这样是不行的 会报错
ORA-00909: invalid number of arguments
ORA-00909: invalid number of arguments
#6
SQL> select * from t4;
ID1 ID2
---------- ----------
1 2
1 3
1 2
--查看某一列不同的记录数
SQL> select count(distinct id1) from t4;
COUNT(DISTINCTID1)
------------------
1
SQL> select count(distinct id2) from t4;
COUNT(DISTINCTID2)
------------------
2
--查看表中各列不同记录数
SQL> select count(distinct id1||id2) from t4;
COUNT(DISTINCTID1||ID2)
-----------------------
2
#1
oracle:
select count(distinct id||adress) form tb;
sqlserver:
select count(distinct id+adress) form tb;
select count(distinct id||adress) form tb;
sqlserver:
select count(distinct id+adress) form tb;
#2
select count(distinct id,adress) from T
#3
统计单个字段的非重复记录条数:
select count(distinct id) from t
统计多个字段的非重复记录条数:
SELECT COUNT(*) FROM(select count(distinct id,adress) from t)
统计所有字段的非重复记录条数:
select count(distinct *) from t
select count(distinct id) from t
统计多个字段的非重复记录条数:
SELECT COUNT(*) FROM(select count(distinct id,adress) from t)
统计所有字段的非重复记录条数:
select count(distinct *) from t
#4
一楼经典,巧妙
#5
这样是不行的 会报错
ORA-00909: invalid number of arguments
ORA-00909: invalid number of arguments
#6
SQL> select * from t4;
ID1 ID2
---------- ----------
1 2
1 3
1 2
--查看某一列不同的记录数
SQL> select count(distinct id1) from t4;
COUNT(DISTINCTID1)
------------------
1
SQL> select count(distinct id2) from t4;
COUNT(DISTINCTID2)
------------------
2
--查看表中各列不同记录数
SQL> select count(distinct id1||id2) from t4;
COUNT(DISTINCTID1||ID2)
-----------------------
2