多个部门的个人影响总数
我有一份报告要简化,但我遇到了一个问题。
(不希望的)报告的行/列当前看起来如下。
部门 | 总 | 缓刑(%) | 暂停(%) |
---|---|---|---|
所有员工 | 32 | 16.3 | 1.4 |
所有团队 | 30 | 23.5 | 2.2 |
总男队总男队 | 10 | 14.8 | 2.8 |
总女队总数 | 34.3 | 1.4 | 男士 |
10 | 穿着10 | 5.9 | 0.0 |
女装 | 10 | 21.4 | 0.0 |
Unisec | 10 | 15.0 | 6.3 |
Wear 因为两个人在两个团队中工作。一个人穿着男装穿着和男女通用的服装工作,一个人在女装和男女通用服装中工作。下表有这样的记录。
COL1 | COL2 |
---|---|
1234 | 男士穿着 |
1234 | 男女通用的 |
9876 | 男女 |
女装9876 | 通用磨损 |
(期望)我正在寻找类似的东西。
部门 | 总 | 缓刑(%) | 暂停(%) |
---|---|---|---|
所有员工 | 30 | 16.3 | 1.4 |
所有团队 | 30 | 23.5 | 2.2 |
总男队 | 10 | 14.8 | 2.8 |
总妇女团队 | 10 | 34.3 | 1.4 |
男士穿着 | 10 | 5.9 | 0.9 0.0 |
女装 | 10 | 21.4 | 0.0 |
UNISEC WEAL | 10 | 15.0 | 6.3 |
我以为关于在Col2上使用ListAgg()来获得这种影响。
COL1 | COL2 |
---|---|
1234 | 男装,男女通用的 |
9876 | 女装, |
使用Listagg()使用UniSEX WEAR为“所有员工”提供了正确的计数,但随后我得到了“男士穿着,男女求衣服”的分组”和“男女通用磨损”。是否可以按照Listagg()'ed Listagg()'ed,或者有更好的方法来实现我的最终结果后,通过单独的逗号分隔值分组?
实现这一目标的任何帮助将不胜感激。
I have a report I am trying to simplify but I am running into an issue.
(Undesired) The rows/columns of the report currently look like the following.
Department | Total | Probation (%) | Suspended (%) |
---|---|---|---|
All Employees | 32 | 16.3 | 1.4 |
All Teams | 30 | 23.5 | 2.2 |
Total Men's Teams | 10 | 14.8 | 2.8 |
Total Women's Teams | 10 | 34.3 | 1.4 |
Men's Wear | 10 | 5.9 | 0.0 |
Women's Wear | 10 | 21.4 | 0.0 |
UniSec Wear | 10 | 15.0 | 6.3 |
This is happening because two people work on two teams. One person works in Mens Wear and UniSex Wear, and one person works in Women's Wear and UniSex Wear. The below table has records like this.
Col1 | Col2 |
---|---|
1234 | Men's Wear |
1234 | UniSex Wear |
9876 | Women's Wear |
9876 | UniSex Wear |
(Desired) Im looking for something like this.
Department | Total | Probation (%) | Suspended (%) |
---|---|---|---|
All Employees | 30 | 16.3 | 1.4 |
All Teams | 30 | 23.5 | 2.2 |
Total Men's Teams | 10 | 14.8 | 2.8 |
Total Women's Teams | 10 | 34.3 | 1.4 |
Men's Wear | 10 | 5.9 | 0.0 |
Women's Wear | 10 | 21.4 | 0.0 |
UniSec Wear | 10 | 15.0 | 6.3 |
I have thought about using LISTAGG() on Col2 to get this affect.
Col1 | Col2 |
---|---|
1234 | Men's Wear,UniSex Wear |
9876 | Women's Wear,UniSex Wear |
Using LISTAGG() gives me the correct count for "All Employees" but then I get groupings of "Men's Wear,UniSex Wear" instead of a separate one for "Men's Wear" and one for "UniSex Wear". Is it possible to group by the individual comma separated values in Col2 after they have been LISTAGG()'ed, or is there a better way of achieving my end results?
Any assistance on achieving this would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议单独纠正All_employes数据,而不是进行ListAgg。
或者
使用一个单独的表来列表和un-listagg您的数据,这与用于计算UN-Listagg的总数,缓刑和悬挂数据的原始表不同
您可以使用以下示例,其中Table_two是您的源表。
I would advise correcting the All_Employees data alone instead of doing the LISTAGG.
OR
Use a separate table to LISTAGG and un-LISTAGG your data which is different from the original table used to calculate the Total, Probation and Suspended data
For un-LISTAGG you can use the below example where table_two is your source table.