query consultar tempo assitido das aulas vimeo

SELECT
c.post_title AS curso_nome,
a.post_title AS aula_nome,
u.display_name AS aluno_nome,
u.user_email AS aluno_email,
CONCAT(
LPAD(FLOOR(tv.tempo / 3600), 2, ‘0’), ‘:’,
LPAD(FLOOR((tv.tempo % 3600) / 60), 2, ‘0’), ‘:’,
LPAD((tv.tempo % 60), 2, ‘0’)
) AS tempo_assistido,
CONCAT(
LPAD(FLOOR(tv.duracao_total / 3600), 2, ‘0’), ‘:’,
LPAD(FLOOR((tv.duracao_total % 3600) / 60), 2, ‘0’), ‘:’,
LPAD((tv.duracao_total % 60), 2, ‘0’)
) AS duracao_total,
tv.data_registro

FROM wp_tempo_video tv

— Curso
INNER JOIN wp_posts c
ON tv.curso_id = c.ID AND c.post_type = ‘sfwd-courses’

— Aula (pode ser lesson ou topic dependendo do LearnDash)
INNER JOIN wp_posts a
ON tv.aula_id = a.ID AND a.post_type IN (‘sfwd-lessons’, ‘sfwd-topic’)

— Aluno
INNER JOIN wp_users u
ON tv.user_id = u.ID

— Só exibe entradas com tempo > 0 e títulos existentes
WHERE tv.tempo > 0

ORDER BY c.post_title, u.display_name, a.post_title;

Rolar para cima