I know how to write a query in MS SQL

select m.date, count(*) as count, (select count(*) from posts n where n.date <= m.date) ) as total from posts m group by m.date order by 1 

But in PostgreSQL this query does not work. Error around from. How to rewrite the request? can a PostgreSQL server read requests differently than MS SQL?

    1 answer 1

    This query cannot work in any DBMS, because there is a banal syntax error in it - an extra closing bracket before as .

    But for good in MS SQL and in postgresql, you should get rid of the subquery and rewrite it like this:

     select m.date, count(*) as count, sum(count(*)) over(order by date) as total from posts m group by m.date order by 1