[英]How assing new column value for only specific one
I have a bit complex query to do in BigQuery.我在 BigQuery 中有一些复杂的查询要做。
Please find below example.请在下面找到示例。
I have:我有:
Team![]() |
Team type![]() |
---|---|
Team 1![]() |
B1 ![]() |
Team 1![]() |
B2 ![]() |
Team 2![]() |
B3 ![]() |
Team 2![]() |
B4 ![]() |
Team 3![]() |
B5 ![]() |
Team 3![]() |
B6 ![]() |
I need to have我需要有
Team![]() |
Teamtype![]() |
Team_model![]() |
---|---|---|
Team 1![]() |
B1 ![]() |
Team x![]() |
Team 1![]() |
B2 ![]() |
Team 1![]() |
Team 2![]() |
B3 ![]() |
Team 2![]() |
Team 2![]() |
B4 ![]() |
Team 2![]() |
Team 3![]() |
B5 ![]() |
Team 3![]() |
Team 3![]() |
B6 ![]() |
Team 3![]() |
In similar logic like this类似这样的逻辑
CASE WHEN teamtype = A1 THEN "Team x" ELSE team_model = %team% END AS team_model CASE WHEN teamtype = A1 THEN "Team x" ELSE team_model = %team% END AS team_model
I know that in biq query you cant do this way.我知道在 biq 查询中你不能这样做。 Would anyone know please how to perform this type of action?
请问有人知道如何执行此类操作吗?
Thank you!谢谢!
Regards, Martin问候, 马丁
You were on the right track.你走在正确的轨道上。 You may use this version:
你可以使用这个版本:
SELECT Team, Teamtype, CASE Teamtype WHEN 'B1' THEN 'Team x' ELSE Team END AS Team_model
FROM yourTable
ORDER BY Team, Teamtype;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.