'SQL - Trouble counting values

I have a Database named 'IDMS' and it has two columns named 'Table' and 'Column'. I Need to do a simple query, list the values in 'Column' with a count of duplicates.

I tried this

Select `'Colum', Count(*)
From IDMS
GROUP by 'Column';`

and not joy. I have tried differing variations of that select and it's not working.

Can anyone assist?

-Ron

sql


Solution 1:[1]

First, I believe you should remove the quotes (') around your "Column" column (I assume its a column from your table and you dont want a fixed 'Column' value as return). Also there is a spelling difference between your first Colum, and second ColumN values; so I will asume first field is named Column1 and second, Column2.

Second, to add the required condition to your query you should use HAVING clause with the desired requirement. For example, if you want result that have more than 1 occurrence of Column2 column in your table:

SELECT Column1, COUNT(Column2)
FROM IDMS
GROUP BY Column1
HAVING COUNT(Column2) > 1;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mbd