I am doing a selection on a table, but also need the count of the items. Apparently I have to use window functions but can't get it work.
I am doing a simple select query and want to count how many entries are there, so something like:
SELECT * FROM "myTable"
COUNT(*) OVER() AS total
WHERE name='John Doe';
This is not working and I am getting the following error: ERROR: ERROR: syntax error at or near "COUNT" LINE 2: COUNT(*) OVER(name) AS _total
How do I use the window functions to count my entries in a table while doing a query? Am I way off base here?
The
COUNT(*)
is a column in theSELECT
:The
FROM
clause follows theSELECT
clause and ends the definitions of the columns in the result set.