>Am I supposed to start the program with the first line, because I get an error when I do:
>
>;with counts as (select Id, count(Id) as frequency
I posted you code to try in SQL Server Management Studio if you're using SQL Server.
What is your back-end?
If it's not broken, fix it until it is.
My Blog