>What if you don't know in advance how many unique A,B,C,D, etc. you have?
In that case, which apparently is not the case at hand, then you are right, as You will need to build the SQL statement dynamically.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges