I'm using SQLite and I"m really green. Essentially I have a table (example below)
ID Date QuestNum Value
1 1/1/1990 1 0
1 1/1/1990 2 3
1 1/1/1990 3 2
1 1/2/1990 1 5
1 1/2/1990 2 2
1 1/2/1990 3 6
2 1/1/1990 1 6
2 1/1/1990 2 3
2 1/1/1990 3 6
2 1/2/1990 1 2
2 1/2/1990 2 8
2 1/2/1990 3 2
And I would the result of my query to look like this
ID Date Quest1 Quest2 Quest3
1 1/1/1990 0 3 2
1 1/2/1990 5 2 6
2 1/1/1990 6 3 6
2 1/2/1990 2 8 2
The closest I got was
SELECT
ID, Date,
MAX(CASE WHEN QuestNum = "1" THEN Value END) AS Q1,
MAX(CASE WHEN QuestNum = "2" THEN Value END) AS Q2,
MAX(CASE WHEN QuestNum = "3" THEN Value END) AS Q3,
FROM table
GROUP BY subjID, Date
Although this does provide the structure I'm looking for it applies the MAX aggregate function and I'm worried that the resulting query holds data that was different from the original set; such that the values returned in columns Quest 1, Quest 2, Quest 3 are the maximum value from that selected column and not the corresponding data point from the value column.
I'm not sure if it is important to note but the QuestNum can skip at times, so that not everyone receives all questions.
Thanks, qwerty
Please excuse any misnomers in my request, believe me they are all unintentional.