Alex Mikhalev
4 years ago
3 changed files with 24 additions and 0 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
DROP VIEW program_sequences; |
||||
|
||||
CREATE VIEW program_sequences AS |
||||
SELECT psi.program_id program_id, |
||||
json_group_array(json_object( |
||||
'section_id', psi.section_id, |
||||
'duration', psi.duration)) sequence |
||||
FROM program_sequence_items as psi; |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
DROP VIEW program_sequences; |
||||
|
||||
CREATE VIEW program_sequences AS |
||||
WITH psi_sorted AS ( |
||||
SELECT psi.program_id program_id, |
||||
json_object( |
||||
'section_id', psi.section_id, |
||||
'duration', psi.duration) |
||||
obj |
||||
FROM program_sequence_items AS psi |
||||
ORDER BY psi.program_id, psi.seq_num) |
||||
SELECT psi_sorted.program_id program_id, |
||||
json_group_array(json(psi_sorted.obj)) sequence |
||||
FROM psi_sorted |
||||
GROUP BY psi_sorted.program_id; |
Loading…
Reference in new issue