I have a table that has multiple rows associated with each ID but sometimes containing differing info:
Key, ID, Name, Title, Time
4, AA, Abe, NULL, 2018-01-05
3, BB, NULL, Mrs, 2018-01-04
2, AA, NULL, Mr, 2018-01-03
1, BB, Cat, Ms, 2018-01-02
Some of the fields are Nulls, some of the row have differing info for the same columns and ID but there will always be an ID and a timestamp.
I want a query where I can squash Nulls but when there are multiple differing fields choose the latest one. Something like this:
Result =
ID, Name, Title, Time
AA, Abe, Mr, 2018-01-05
BB, Cat, Mrs, 2018-01-04
I have something using "SELECT DISTINCT ON (id, name, title)" but I'm missing the next step so it's not working.
SQL Fiddle: http://sqlfiddle.com/#!17/72ba3/1