【发布时间】:2018-06-12 19:05:48
【问题描述】:
这是我的数据:
BadgeID | Session | Session Type | My_Interest_Area |
___________________________________________
12345 | PG1 | Symposium | COPD
12345 | PG1 | Symposium | Asthma
12345 | PG2 | Symposium | COPD
12345 | PG2 | Symposium | Asthma
12345 | PG3 | Workshop | COPD
12345 | PG3 | Workshop | Asthma
54321 | PG1 | Symposium | ARDS
54321 | PG1 | Symposium | Asthma
我正在尝试得到这个结果:
Interest Area | Symposium Count| Workshop Count
____________________________________
COPD | 1 | 1
Asthma | 2 | 1
ARDS | 1 | 0
最初,我在考虑使用 Where 子句并分隔每个会话类型:
select CDS_Interest_Areas as "Interest Area", round(COUNT(DISTINCT(BadgeID))/count(BadgeID)*100,0) as "Percent" from interest_areas_dataset where CDS_Interest_Areas IS NOT null and `Session Type` = "Symposium"
group by CDS_Interest_Areas
我不需要使用 Where 子句。 我只是想得到结果。
另外,我想得到百分比。表示“兴趣领域”的百分比构成了所说的“会话类型”。
示例: Symposium 有 10% 的哮喘、5% 的 COPD 等……
【问题讨论】:
-
顺便说一句,这是一种更清晰的提问方式:)