When writing a query, LET clauses are an excellent way to make the query easier to read. If the same formula is used multiple places, you can write once and then reference it. However, there is not currently a way to use the result of one clause in the LET statement as input to a second clause in the LET statement.
In the second clause of the LET statement above, DATE_TRUNC_MILLIS(STR_TO_MILLIS(NumberDocs.createDate, 'hour')) is needed twice. So here, we attempt to define this as "createDateByHour" and then reference it in the second clause. This is currently not accepted by the query engine.
|For Gerrit Dashboard: MB-19772|
|99841,3||MB-19772 Chained LETTING variable does not work with GROUP BY||master||query||Status: MERGED||+2||+1|
|100007,2||MB-31423 Intermittent error with chained LETTING variable and GROUP BY||master||query||Status: MERGED||+2||+1|