Skip to content
Advertisement

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

Advertisement

Answer

I’m not sure if I’ve understood your question but if you use reserved names you can just put it []

If you need to know the column/table duplicated, had a the column [table] and if you need to filter it you can just use having like @mimi said

Select 
[Column], 
Count(*),
CASE WHEN Count(*) > 1 THEN 'Yes' ELSE 'NO' END as IsDuplicated 
From IDMS
GROUP by [Column];
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement