Skip to content
Advertisement

I can not convert the data to the required form

Hi hi I have a Nodejs server and I am using PostgreSQL, the bottom part of my database. How can I select data and represent it like this (in one sql query):

I wrote a request but it is far from what I need:

database structure

Advertisement

Answer

You can use a cte to first build the question JSON data, and then aggregate the latter with the lessons:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement