sdworschak sdworschak - 4 months ago 28
SQL Question

Literal field Google Sheets QUERY

Is there a way to add a literal field at the end of a Google Sheets QUERY function similar to what you can do in SQL?

e.g.

=QUERY(A:C,"SELECT A, B, C, D AS 'CURRENT DATA'",0)


Thanks,
Stefan

Answer

Guess, you mean this:

=QUERY(A:C,"SELECT A, B, C, 'D' label 'D' 'CURRENT DATA'",0)

see more info here

The formula above will populate letter 'D', lebaled as 'CURRENT DATA'. If you want actual column D, then use range A:D:

=QUERY(A:D,"SELECT A, B, C, D label 'D' 'CURRENT DATA'",0)