I gave up on finding my own answer to do the following (sigh) :
| city_name | lat | lng |
|---|---|---|
| a | 1 | 10 |
| NULL | 2 | 20 |
| NULL | 3 | 30 |
| b | 2 | 20 |
| c | 3 | 30 |
I am working on a large data set containing a lot of nulls in the column like 'city_name' above. Based on the value in 'lat', 'lng,' I know the first null is 'b' and the second null is 'c'.
The table has over 1000 distinct city names and 15000 nulls that can be corrected by finding the rows having the same lat and lng value. It seems impossible to manually replace nulls with the city name based on latitude(lat column) and longitude(lng column).
I want null value to be the city name based on lat and lng in the same row. Maybe there's a way to refer to other rows having the same lat and lng, get the city name from them and then replace null with the city name?
Is there a way to replace all nulls with the city name at once like the above in POSTGRESQL?
Thanks in advance!