user1538020 user1538020 - 1 year ago 97
SQL Question

Max of a Date field into another field in Postgresql

I have a postgresql table wherein I have few fields such as id and date. I need to find the max date for that id and show the same into a new field for all the ids. SQLFiddle site was not responding so I have an example in the excel. Here is the screenshot of the data and the output for the table.

enter image description here

Answer Source

You could use the windowing variant of max:

SELECT id, date, MAX(date) OVER (PARTITION BY id)
FROM   mytable
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download