Pivoting a table of survey data in SQL without PIVOT

Pivoting a table of survey data in SQL without PIVOT

I have a table called Responses which contains survey responses using the following structure.

RespondentID    | QuestionID | Text gzolehana
----------------+------------+--------------------
745000000144003 | 1          | 424847508003102140
745000000144003 | 2          | someone@example.com
745000000144003 | 3          | 10
745000000144003 | 4          | Long text
745000000137035 | 1          | 548470363003102141
745000000137035 | 2          | someone@me.com
745000000137035 | 3          | 9
745000000137035 | 4          | Long text

This is data for two different survey responses. Each survey has 4 questions (QuestionIDs) but the last one (long text) is optional, so some responses only have 3 rows of data. The first question (QuestionID "1") could also serve as a primary key for a survey response.

I'm trying to pivot the data so each QuestionID is it's own column and so that each survey response is only one row. I'm using Zoho Analytics which I don't believe supports PIVOT.

Thanks for any help!


      • Sticky Posts

      • Connect with Zoho users from your industry, virtually!

        A couple of years ago, we started setting up industry-wise channels for users with similar businesses to chat and discuss Zoho contextually. We started with Real Estate and E-commerce sectors, creating a chatroom and hosting regular meetups on niche areas
      • Feature update: Advanced security settings

        We've previously written about how using security policies could be beneficial for admins. To enable you to better protect your organization, we've come up with a few additional settings for security policies in Zoho One that can be used to regulate your users' web sessions. What are web sessions? A web session refers to the period of time you stay signed in to your Zoho One account. You create a new web session every time you sign in to Zoho One (or any of its included apps), and this session exists