我有一个约150列的表。我想为每列找到count(distinct(colName))
,但是想知道是否有一种方法可以实际输入每个列名。我想使用count(distinct(*))
但这不起作用。SQL Server计数表中每列的不同值的数量
其他建议?
编辑:
如果这是我的表:
id col1 col2 col3 ...
01 10001 west north
02 10001 west south
03 10002 east south
04 10002 west north
05 10001 east south
06 10003 west north
我在寻找这个输出
count(distinct(id)) count(distinct(col1)) count(distinct(col2)) count(distinct(col3))
6 3 2 2
等待有可能有一个单一列名称使用多次?或者你有一个存储列名值的字段? –