I am learning transact sql on https://data.stackexchange.com/
I wrote this snippet to count how many users created just one post.
SELECT COUNT(id) as post_count, OwnerUserId INTO #tb_postcount FROM posts group by OwnerUserId order by post_count desc, OwnerUserId desc; SELECT count(*) from #tb_postcount where post_count =1 group by OwnerUserId order by post_count desc, OwnerUserId desc
And I got
Column "#tb_postcount.post_count" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
I guess this is because temp table in sql-server does not support where clause, I don't even know if sql-server does support or does not.
How to have my query work?