I had two tables, one with polygons and one with points. The table of points had the attributes of value and time. I created a new table at postgis with this query
SELECT polygon.gid, time, avg(value) FROM polygon LEFT OUTER JOIN geo ON ST_Contains(polygon.geom,geo.geom) GROUP BY polygon.gid,time
This created a table, where if the point is inside the polygon I have the average value at different times. The problem that I have is that, if a polygon does not contain any point then the avg(value) is null (which is something that i want to) but also creates a null at time attribute while I want the value of each time. This is for the empty polygons: And this for the polygons with points inside: How I can keep the time attribute for the empty polygons?