This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

Given a table that specifies the results of a survey taken by 8 participants. As can be seen: each participant was presented with 7 questions, and each questions could be responded with either 1 or 2. 1 indicates “Yes”, 2 indicates “No”.


CREATE TABLE Survey
(Person varchar(25),
Q1 int,
Q2 int,
Q3 int,
Q4 int,
Q5 int,
Q6 int,
Q7 int)
GO

Would you like to read more?