SQLTeam.com | Weblogs | Forums

Equivalent of PCD.Value for Quantities?


#1

I'm fairly new to SQL, so this may be obvious.
In the system I'm working on, we have users/doctors answer questions about their patients, usually using radio buttons, and then we calculate the percentage of Y's and N's. In our system, we have SQL to determine this percentage.
Typically it looks like
(PCD.QuestionID=3854 AND PCD.Value='1')
to indicate that the question was answered Yes. However, we have one question that uses checkboxes, and the question is considered 'Yes' if more than one checkbox is selected. In JavaScript it looks like
($('#Q3854 input:checked').size() > 1)

So, basically what I'm asking is: is there anything I can put in place of PCD.Value to determine whether the quantity of checkboxes is correct? Something like PCD.Quant or PCD.Amt or whatever?


#2

Assuming that PCD.Value takes on values of 1 and 0,

SUM(PCD.Value) OVER(PARTITION BY PCD.QuestionID) >= 1