SQL语句记录

UPDATE EXAM_SCORE t1
SET end_class_time = (
	SELECT create_date_time
	FROM (
		SELECT MAX(create_date_time) AS create_date_time, exam_score_id
		FROM ANSWER_RECORD t
		WHERE t.exam_score_id IN (
			SELECT e.id
			FROM EXAM_SCORE e
			WHERE e.end_class_time IS NULL
		)
		GROUP BY t.exam_score_id
	) t2
	WHERE t1.id = t2.exam_score_id
)
WHERE EXISTS (
		SELECT create_date_time
		FROM (
			SELECT MAX(create_date_time) AS create_date_time, exam_score_id
			FROM ANSWER_RECORD t
			WHERE t.exam_score_id IN (
				SELECT e.id
				FROM EXAM_SCORE e
				WHERE e.end_class_time IS NULL
			)
			GROUP BY t.exam_score_id
		) t2
		WHERE t2.exam_score_id = t1.id
	)
posted @ 2020-11-02 07:47  晴和琼林  阅读(75)  评论(0编辑  收藏  举报