I am new to PostgreSQL and I don't know why my "as" statement is not working, below is the query:
with CTE as
(
SELECT *,rank() OVER(partition by Name ORDER BY AdministrationDate desc) AS rank_val
FROM ExamResult
)
select Name as 'Student Name', AdministrationDate as 'Admin date most recent',Score as 'Most Recent Score'
where rank_val=1 from CTE
UNION
select Name as 'Student Name', AdministrationDate as 'Admin date Prior attempt',Score as 'Prior Score'
where rank_val=2 from CTE
Is as not a part of Postgres