数据库表某一列中相同值的个数
今天整理一大堆数据(一共900行数据),我发现仓库管理员可能在处理这些数据时出错了,所在验证了一下。
我使用了以下SQL语句:
Select [1],count([1]) as Qty from
(SELECT [1] FROM [Shelfs]
union all SELECT [2] FROM [Shelfs]
union all SELECT [3] FROM [Shelfs]
union all SELECT [4] FROM [Shelfs]
union all SELECT [5] FROM [Shelfs]
union all SELECT [6] FROM [Shelfs]
union all SELECT [7] FROM [Shelfs]) a where [1]<>” group by [1] order by Qty desc
得出的结果很清楚地可以看到,有的是相同的数据,而我需要的是不同的数据,即他整理重复了。特别记录一下。
you see, if you want to get the distinct record,you can use the distinct value.not use the “union” to unite all the selected records.maybe the speed is not good.
Hello, this is just a tool, I use this SQL string to check the data is ok or not.
I only need to execute it one time.
Do you understand?