This question, to my eyes, deserves a lot of credit for being clear, providing good examples, and is pretty much exactly what we want from a new poster.
That said, it's not particularly well-researched, and the problem he is having is a definite duplicate of a scenario already asked and answered on Stack Overflow (searches for SQL Pivot JOIN
would show several of them).
The poster is new enough to SQL that the lack of technical understanding is completely understandable, though, and based on comments he (incorrectly) assumed he couldn't use PIVOT
in conjunction with a JOIN
, and thus wouldn't have realized that it applied to his question.
What should I do? Should the question be:
a) upvoted because of good writing
b) downvoted because of insufficient research
c) voted to close as duplicate
d) some combination thereof?
I already left a comment congratulating the poster on their question, pointing them towards other questions and Google phrasings that might help, and letting them know that they might be closed as a duplicate, but I'd like to know how the system should handle congratulating them on the one hand while dealing with the duplicate on the other.
EDIT: Some additional information about the original post:
1) The question title is not, in itself, the right way to express what he wants ... my reference above to a Google search represents my understanding of the method he needs, not the OP's. I know that what he's looking for is a
PIVOT
- he didn't.2) The poster had already found posts about the correct answer (in this case,
PIVOT
) but assumed incorrectly that they did not apply to him because most tutorial examples don't include a JOIN.3) If the poster had gone a step further and asked Google if you could use a JOIN with a PIVOT, he would have found his answer easily.