本文介绍了如何使用sqlserver进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须进行查询
我的表结构是这样的
i have to make query
My table structure is like this
towncodeNo TownName
2023001 M1
2023001 M1
2031025 Z1
2031025 Z1
2031030 Z1
结果应该是
Result should be
Townname Total
M1 1
Z1 2
请帮助我使用SQLServer 05
Kindly help me to make query using SQLServer 05
推荐答案
SELECT TownName, COUNT(TownName) - 1 AS Total FROM myTable GROUP BY TownName
select TownName, Count(Distinct(towncodeNo )) from tblSample group by TownName;
这篇关于如何使用sqlserver进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!