对于 Oracle-Noob 问题,我很抱歉,但我在尝试运行的查询时遇到问题,似乎无法弄清楚如何编写它。
如果我将查询分成两部分,我会得到每个部分的正确信息。看:
select NVL (skill.category, 'Total:') "Skill Category",
count (training.code) "# of Trainings"
from skill join training on skill.code = training.code
group by rollup (skill.category);
返回:
Skill Category # of Trainings
--------------- --------------
Database 2
HR 1
Leadership 1
Printing 1
Sales 3
Web Design 5
Total: 13
同样,对于第二个查询,我得到以下信息:
select NVL (skill.category, 'Total:') "Skill Category",
count (project.code) "projects req training"
from skill join project on skill.code = project.code
group by rollup (skill.category);
Skill Category projects req training
--------------- ---------------------
Database 2
Printing 3
Web Design 5
Total: 10
但是,当我尝试组合这些查询时,我的结果被搞砸了:
select NVL (skill.category, 'Total:') "Skill Category",
count (training.code) "# of Trainings",
count (project.code) "Projects Requiring Skill"
from skill join training on skill.code = training.code
left join project on training.code = project.code
group by rollup (skill.category);
Skill Category # of Trainings Projects Requiring Skill
--------------- -------------- ------------------------
Database 4 4
HR 1 0
Leadership 1 0
Printing 3 3
Sales 3 0
Web Design 13 13
Total: 25 20
我在这里做错了什么?我非常感谢任何帮助,如果我遗漏了一些明显的东西,我很抱歉!