Finding difference between total value and distinct value in a table Finding difference between total value and distinct value in a table database database

Finding difference between total value and distinct value in a table


Use COUNT and DISTINCT COUNT.

SELECT COUNT(name)-COUNT(DISTINCT name) AS nameDifferenceFROM city

Output:

nameDifference1


Try this

SELECT COUNT(Name)-COUNT(DISTINCT Name) AS NewNameFROM city


you can use DISTINCT and COUNT.

SELECT COUNT(name) - COUNT(DISTINCT name) FROM city