Hi, I'm new to the SQL language and PostgreSQL. I was getting familiar with the language and was following a PostgreSQL tutorial until I got stuck at a chapter about Window Functions (link text. I created the exact same table 'empsalary' as shown in the example:
wtouw=# SELECT * FROM empsalary; depname | empno | salary -----------+-------+-------- develop | 11 | 5200 develop | 7 | 4200 develop | 9 | 4500 develop | 8 | 6000 develop | 10 | 5200 personnel | 5 | 3500 personnel | 2 | 3900 sales | 3 | 4800 sales | 1 | 5000 sales | 4 | 4800 (10 rows)
and copy-pasted the first statement that uses a window function:
SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary;
However, I got the following error message:
ERROR: syntax error at or near "OVER" LINE 1: SELECT depname, empno, salary, avg(salary) OVER (PARTITION B... ^
Other efforts to use the OVER clause also didn't work.
What did I do wrong?
Thanks.
Version info: PostgreSQL 8.3.8 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)