52 lines
1.3 KiB
SQL
52 lines
1.3 KiB
SQL
-- 仅查询课件时长情况(只读操作,不需要修改权限)
|
||
-- 执行日期:2025-12-05
|
||
|
||
USE ry_study;
|
||
|
||
-- 1. 查看当前课程1的所有课件时长情况
|
||
SELECT
|
||
id,
|
||
name,
|
||
type,
|
||
duration,
|
||
file_path,
|
||
CASE
|
||
WHEN duration IS NULL THEN '⚠️ NULL'
|
||
WHEN duration = 0 THEN '⚠️ 0'
|
||
ELSE '✅ 正常'
|
||
END as status
|
||
FROM courseware
|
||
WHERE course_id = 1
|
||
ORDER BY id;
|
||
|
||
-- 2. 检查学习详情中的最大播放位置(可以作为duration的参考)
|
||
SELECT
|
||
c.id as courseware_id,
|
||
c.name,
|
||
c.type,
|
||
c.duration as configured_duration,
|
||
MAX(ld.video_end_position) as max_position,
|
||
COUNT(ld.id) as record_count,
|
||
CASE
|
||
WHEN c.duration IS NULL OR c.duration = 0 THEN
|
||
CONCAT('建议设置为: ', MAX(ld.video_end_position))
|
||
WHEN MAX(ld.video_end_position) > c.duration THEN
|
||
CONCAT('⚠️ 实际更长: ', MAX(ld.video_end_position), '秒')
|
||
ELSE '✅ 正常'
|
||
END as recommendation
|
||
FROM courseware c
|
||
LEFT JOIN learning_detail ld ON ld.courseware_id = c.id
|
||
WHERE c.course_id = 1
|
||
GROUP BY c.id, c.name, c.type, c.duration
|
||
ORDER BY c.id;
|
||
|
||
-- 3. 查看课件882和873的具体情况
|
||
SELECT
|
||
id,
|
||
name,
|
||
type,
|
||
duration,
|
||
file_path
|
||
FROM courseware
|
||
WHERE id IN (882, 873) AND course_id = 1;
|