質問

I have a query like this =QUERY(B2:C9; "select (C * 100 / B) - 100") in my Google Sheets. What is displayed as a column header is:

difference(quotient(product(100.0()))100.0()).

I want to put a human readable description there instead.

How can I achieve this?

役に立ちましたか?

解決

=QUERY(B2:C9;"select (C*100/B)-100 label (C*100/B)-100 'Value'")

https://developers.google.com/chart/interactive/docs/querylanguage#Label

他のヒント

Remember there is a trick there.

Working example of the query:

"SELECT C, COUNT(C), AVG(G), AVG(E) GROUP BY C ORDER BY COUNT(C) DESC LABEL COUNT(C) 'My count' FORMAT AVG(G) '##0.00', AVG(E) '##0.00'"

Not working example of the query:

"SELECT C, COUNT(C) LABEL COUNT(C) 'My count', AVG(G), AVG(E) GROUP BY C ORDER BY COUNT(C) DESC FORMAT AVG(G) '##0.00', AVG(E) '##0.00'"

Also not working example of the query:

"SELECT C, COUNT(C), AVG(G), AVG(E) GROUP BY C ORDER BY COUNT(C) DESC FORMAT AVG(G) '##0.00', AVG(E) '##0.00' LABEL COUNT(C) 'My count'"

It works ONLY if it's placed in the correct order with other commands.

It's counter-intuitive, but you must define your relabeled column TWICE; once in the "SQL" string, and then append the label clause to the end of the SQL string.

So, if you want to select A, B, C with "B" being labeled as "Foo", you would do this:

=QUERY(B2:C9;"select A, B, C   label B 'Foo' ")

If you're doing calculations, be careful to exactly match the SQL string definition and the label definition. For example:

=QUERY(B2:C9;"select A, B*2, C   label B*2 'Foo' ")

https://developers.google.com/chart/interactive/docs/querylanguage#Label

If you want to rename more than one column, it uses one LABEL keyword, then separate the fields and their new name assignments using a comma.

"select B, D, D*C where D <> 0 label D 'Staff', D*C 'Cost'"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top