[MONDRIAN-1512] Correcting the inline SQL used by Impala.

(cherry picked from commit 2d37427)
Merge pull request #145 from mkambol/lag-mon1512

[MONDRIAN-1512] Correcting the inline SQL used by Impala.