I am not able to define an alias or to choose specific columns, works only with wildcard:
Working:
SELECT DISTINCT ON (r.InsertDate) *
FROM public.server AS s
LEFT JOIN public.Report AS r ON s.Id = r.ServerId
ORDER BY r.InsertDate DESC;
Not working :
SELECT DISTINCT ON (r.InsertDate) LastReport, s.Id, s.Servername
FROM public.server AS s
LEFT JOIN public.Report AS r ON s.Id = r.ServerId
ORDER BY r.InsertDate DESC;
Error
ERROR: column "lastreport" does not exist
LINE 1: SELECT DISTINCT ON (r.InsertDate) LastReport, s.Id, s.Serve...
^
SQL state: 42703
Character: 36
Also not working:
SELECT DISTINCT ON (r.InsertDate) , s.Id, s.Servername
FROM public.server AS s
LEFT JOIN public.Report AS r ON s.Id = r.ServerId
ORDER BY r.InsertDate DESC;
ERROR: column "lastreport" does not exist
LINE 1: SELECT DISTINCT ON (r.InsertDate) LastReport, s.Id, s.Serve...
^
SQL state: 42703
Character: 36
ERROR: syntax error at or near ","
LINE 1: SELECT DISTINCT ON (r.InsertDate) , s.Id, s.Servername
^
SQL state: 42601
Character: 36
Any idea?