Can I, on a simple query, obtain the last NOT NULL value from a table like this?
ID | Name | Inserted_at | Custom.Value1 | Custom.Value2 1 | Allan | 2017-08-01 | NULL | NULL 1 | NULL | 2017-08-03 | Value1 | NULL 1 | NULL | 2017-08-05 | Value2 | Value3 2 | Jones | 2017-08-02 | NULL | NULL
The value that I expect to return is some like:
1 | Allan | 2017-08-05 | Value2 | Value3 2 | Jones | 2017-08-02 | NULL | NULL
I know that Updates on BigQuery are nearly impossible and a naive MAX/GROUP/ORDER BY does not seems to be right.
Anyone have some idea how to solve this?
Thanks!
DISTINCT
and the performance hit. The ARRAY_AGG() function I had never seen before. Looks like exactly what you need, I wish I had known it existed. I wonder if it avoids the performance problems of window functions? – Chris Berger