表格:jd1(可比性表格)
表:data1(新值表)
我已在运行中的sql server中编写了此查询,但在蜂巢中却显示了错误
select * from data1;
1 siva hadoop
1 siva hive
1 siva spark
1 siva hbase
1 siva mapreduce
1 siva hdfs
2 kumar hadoop
2 kumar hive
2 kumar python
2 kumar spark
3 naveen hive
3 naveen hadoop
3 naveen flume
3 naveen kafka
从jd1中选择*;
1 hadoop
1 hive
1 spark
1 hbase
1 mapreduce
1 hdfs
1 python
1 java
预期产量
1 siva 6 85.71428571428571
2 kumar 4 57.142857142857146
3 naveen 2 28.571428571428573
我的查询
select id, name, count(*), ((count(*)*100)/(select count(skills)from jd1))avg
from (select n.id, n.name, n.skills
from data1 n join jd1 t on (n.skills=t.skills))a
group by id,name;
错误
FAILED: ParseException line 1:44 cannot recognize input near 'select' 'count' '(' in expression specification
答案 0 :(得分:1)
select id, name, count(*) cnt, count(*)*100/skill_cnt cnt_pct
from (select n.id, n.name, n.skills, t.skill_cnt
from data1 n
inner join (select skills, count(*) over() skill_cnt from jd1) t
on n.skills=t.skills
) a
group by id,name;
答案 1 :(得分:0)
您可以在下面的查询中尝试-
SELECT n.id, n.name, COUNT(n.skills), COUNT(n.skills)/skill_cnt.total_skill
FROM data1 n
JOIN jd1 t ON n.skills=t.skills
CROSS JOIN (SELECT COUNT(*) total_skill FROM jd1) skill_cnt
GROUP BY n.id, n.name, total_skill
答案 2 :(得分:0)
为jd技能再创建一个表,作为skill_count并加入该表。
SELECT n.Id, n.Job_Id, n.Name, n.Email, n.Mobile_Number, n.Education, n.Total_Experiance,((count(n.skills)*100)/s.skill_count) Average
FROM new_resume n
JOIN new_jd t ON n.skills=t.skills
JOIN skill_count s ON n.job_id = s.job_id
GROUP BY n.Id, n.Job_Id, n.Name, n.Email, n.Mobile_Number, n.Education, n.Total_Experiance,s.skill_count;