简体   繁体   English

如何只为特定的一个分配新的列值

[英]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团队 1 B1 B1
Team 1团队 1 B2 B2
Team 2团队 2 B3 B3
Team 2团队 2 B4 B4
Team 3第 3 队 B5 B5
Team 3第 3 队 B6 B6

I need to have我需要有

Team团队 Teamtype团队类型 Team_model团队模型
Team 1团队 1 B1 B1 Team x团队 x
Team 1团队 1 B2 B2 Team 1团队 1
Team 2团队 2 B3 B3 Team 2团队 2
Team 2团队 2 B4 B4 Team 2团队 2
Team 3第 3 队 B5 B5 Team 3第 3 队
Team 3第 3 队 B6 B6 Team 3第 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.

相关问题 如何使用 SQL 在表中创建一个新列以仅显示来自另一列的特定数据? - How can I create a new column in a table to show only specific data from another column using SQL? 如何将表列转换为一个新列 - how to convert table columns to one new column Flutter Firebase StreamBuilder如何只使用一个特定文件 - Flutter Firebase StreamBuilder how to use only one specific document 如何返回特定列中只有 integer 个值的所有记录? - How to return all records having only integer values in a specific column? 创建新的 sql 列以获得新的价值 - create new sql column to get new value 当类型仅为服务时,如何获得新的列顺序 - how can I get a new column order sequence when type is only service 如何从一列中找到前 3 个返回值中的每一个,从另一列中查找前 3 个返回值? - How to find for each of the top 3 returned value from one column, the 3 top values from another column? 如何删除一列中的所有重复项并仅返回 SQL 中下一列中具有日期的那些? - How to delete all duplicates in one column and return only those that has date in next column in SQL? 如何在 firebase v9 的 firesrore 中为每个用户只更新一次特定字段的数据? - How to update a specific field of data only one time for each user in firesrore in firebase v9? 如何仅将包含特定文本的文件从一个 Google 存储桶移动到另一个 - How to move only files that contains specific text from one Google bucket to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM