asp.net - How can I count different values stored in one cell in SQL? -


i have survey, questions yes or no answers. made 1 page in asp.net , of questions radio buttons , answers same text in .net.

.aspx:

asp:radiobutton id="money1" runat="server" groupname="money" text="yes"  asp:radiobutton id="money2" runat="server" groupname="money" text="no"   

.aspx.cs:

 if (money1.checked)                 { cmd.parameters.add(new sqlparameter("@money", money1.text)); }   else if (money2.checked)                 { cmd.parameters.add(new sqlparameter("@money", money2.text)); } 

sql field:

money   nvarchar(50)    checked 

now ok, , result stored in db requested.

but have make report , i'm trying make sql view count results of yes , no questions, specifically, how many people answered yes , no? can see, both results stored in 1 cell.

so, correct sql statement should use catch count of answer different result.

select money,        count(*)   [table] group money 

a group statement group results categories based on values of field(s) give group on. in example grouping on money means instances of yes grouped , instances of no grouped , counted separately.

it's worth noting if you're using yes/no answers questions bit field efficient way store data in database.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -