Sql 如何操作一对多配置单元表中相关表的结果

Sql 如何操作一对多配置单元表中相关表的结果,sql,hive,Sql,Hive,我有如下数据: 帐目 身份证件 1. 2. 3. 您可以使用聚合: select id, max(case when sale_location = 'online' and sale_type = 'big' then 1 else 0 end) as has_big_online, max(case when sale_location = 'in_store' and sale_type = 'big' then 1 else 0 end) as has_big

我有如下数据:

帐目

身份证件 1. 2. 3.
您可以使用聚合:

select id,
       max(case when sale_location = 'online' and sale_type = 'big' then 1 else 0 end) as has_big_online,
       max(case when sale_location = 'in_store' and sale_type = 'big' then 1 else 0 end) as has_big_online,
from t
group by id;
注意:布尔值的行为取决于配置单元的版本,因此这只对列使用1/0标志