Created
January 18, 2018 10:04
-
-
Save KDamir/21d7a631e6bfdc0368a63dd26d34a20f to your computer and use it in GitHub Desktop.
sub-select
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select questoin_id, question_text, prev, next from | |
(select t0.questoin_id,t0.question_text, | |
lag(t0.questoin_id) over (order by t0.questoin_id, t0.questoin_id rows between current row and unbounded following) as prev, | |
lead(t0.questoin_id) over (order by t0.questoin_id, t0.questoin_id rows between current row and unbounded following) as next | |
from public.result_question t0 inner join public.question t1 | |
inner join public.scenario_subject t2 on t1.scenario_id = t2.scenario_id | |
and t1.subject_id = t2.subject_id | |
on t0.questoin_id = t1.question_id | |
where t0.event_record_id = 42 order by t0.questoin_id) as tbl | |
where questoin_id = 33 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment