本文介绍了SQL查询使用Column1值和column2值相同显示计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
sno Name1 Name2 Data
-----------------------
1 Jai Jai 20
2 mani mani 30
3 kumar ganesh 40
4 siva kumar 50
5 sai sai 60
SQL查询是=从表名中选择Count(*)作为countt,其中(Name1 == Name2)
i这是我自己的查询,这是错误的。
i想要的输出是:
Countt
------
3
sno Name1 Name2 Data
-----------------------
1 Jai Jai 20
2 mani mani 30
3 kumar ganesh 40
4 siva kumar 50
5 sai sai 60
SQL Query is = Select Count(*) as countt from tablename where (Name1 == Name2)
i thing this is my own query this s wrong one.
i want the output is :
Countt
------
3
推荐答案
Select Count(*) as countt from tablename where Name1 = Name2
SELECT COUNT(*) FROM tablename WHERE Name1 = Name2
这篇关于SQL查询使用Column1值和column2值相同显示计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!