json sql语句

18 篇文章 0 订阅
5 篇文章 0 订阅
select  d.major_id as majorId,c.grade,
        c.course_start_time as courseStartTime,c.course_end_time as courseEndTime,
        p.name as projectName,p.semester,d.name as directionName,
				c.teacher_name as teacherName,c.total
from course c,project p,direction d
where p.id = c.project_id and d.id = c.direction_id and c.enterprise_id = 6 and c.id = 6 



-- 例子 ok 
SELECT  avg (t1.rowobj -> '$.score') as s
SELECT  a.rowobj -> '$.score' -> '$[0][0]'
-- ,t1.r2 -> '$.score' as zx
FROM
(
SELECT answers->'$[0][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
UNION ALL
SELECT answers->'$[1][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
UNION ALL
SELECT answers->'$[2][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
UNION ALL
SELECT answers->'$[3][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
UNION ALL
SELECT answers->'$[4][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
UNION ALL
SELECT answers->'$[5][0]' AS rowobj FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
) a

WHERE t1.course_id = 1;

-- 评价分 ok 
SELECT avg (ssj.score -> '$.score') as score
FROM
(
SELECT answers->'$[0][0]' AS score FROM student_survey_info
WHERE student_survey_info.course_id = 1
) ssj;

-- 数量
-- ok 
SELECT count(*)
FROM
(
SELECT answers->'$[0][0]' AS score FROM student_survey_info
-- WHERE student_survey_info.course_id = 1
) ssj;







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值