I have the following table in Postgresql:
sch_code sch_level start_date end_date flag
1234 P 01-01-2018 31-01-2018 V
1234 S 01-01-2018 31-01-2018 V
5678 S 01-01-2018 31-01-2018 V
8965 P 01-01-2018 31-01-2018 V
The result which I require is as follows.
sch_code start_P end_P start_S end_S
1234 01-01-2018 31-01-2018 01-01-2018 31-01-2018
5678 00-00-0000 00-00-0000 01-01-2018 31-01-2018
8965 01-01-2018 31-01-2018 00-00-0000 00-00-0000
The queries which i tried with UNION
did not provide a result. I have also tried using looped select statements.