我的语句的意思是查处子公司一,人力资源部门,由多少人,其中 博士由多少人,
EXEC SQL DECLARE cur_Man CURSOR FOR
SELECT company as 公司,depart as 部门,count(*) as 人数,(select count(*) from machineinfoque where degree='博士' and company=:strCompany and depart=:strDepart) as 博士生数量
FROM people t where t.company=:strCompany and t.depart=:strDepart
GROUP BY (company,depart);
EXEC SQL OPEN cur_Man;我在编译的时候,老是出错。不知道语句哪里有问题。。请高手指教!
表结构:(公司,部门,姓名,教育程度, 入职时间
company depart names degree InDate
子公司一 人力资源部门 陈三 本科 20080101
子公司二 人力资源部门 李四 本科 20080304
子公司一 人力资源部门 张力 博士 20090301
子公司一 后勤部门 李庆 大专 20090322
子公司一 人力资源部门 张思 硕士 20100211
EXEC SQL DECLARE cur_Man CURSOR FOR
SELECT company as 公司,depart as 部门,count(*) as 人数,(select count(*) from machineinfoque where degree='博士' and company=:strCompany and depart=:strDepart) as 博士生数量
FROM people t where t.company=:strCompany and t.depart=:strDepart
GROUP BY (company,depart);
EXEC SQL OPEN cur_Man;我在编译的时候,老是出错。不知道语句哪里有问题。。请高手指教!
表结构:(公司,部门,姓名,教育程度, 入职时间
company depart names degree InDate
子公司一 人力资源部门 陈三 本科 20080101
子公司二 人力资源部门 李四 本科 20080304
子公司一 人力资源部门 张力 博士 20090301
子公司一 后勤部门 李庆 大专 20090322
子公司一 人力资源部门 张思 硕士 20100211
with tb as(
select '子公司一' company,'人力资源部门' depart,'陈三' names,
'本科' degree,'20080101' InDate from dual union all
select '子公司二', '人力资源部门', '李四', '本科', '20080304' from dual union all
select '子公司一', '人力资源部门', '张力', '博士', '20090301' from dual union all
select '子公司一', '后勤部门', '李庆', '大专', '20090322' from dual union all
select '子公司一', '人力资源部门', '张思', '硕士', '20100211' from dual)
--以上为提供数据的语句
select company 公司,depart 部门,count(*) 人数,
sum(decode(degree,'博士',1,0)) 博士数量
from tb
group by company,depart公司 部门 人数 博士数量
-------- ------------ ---------- ----------
子公司二 人力资源部门 1 0
子公司一 后勤部门 1 0
子公司一 人力资源部门 3 1
把你的全部贴出来 你的游标声明语法不是oracleselect company,depart,count(*) 总人数,sum(decode(degree,'博士',1,0)) "博士人数"
from tb
where company=&company and depart=&depart
group by company,depart