什麼是計算從PollResponses表投票結果爲特定PollId按分貝圖所示的模式最好的和有效的方式簡單的SQL查詢來計算投票結果
我想有以下類型的數據如果我們有特定的調查
optionText
count
optiontext
count
optiontext
count
optiontext
count
例如,四個選項
Obama
2000
Romney
1800
Clinton
3000
Xyz
1200
個
共8行使用下面的查詢
select options.OptionText as [optionText]
,count(responses._id) as [count]
from Polls polls
inner join PollOptions options on options.PollId = polls._id
inner join PollResponses responses on responses.PollId = polls._id
where polls._id = 104
group by options.OptionText, polls._id
與pollresponse表的這個數據
即時得到這個結果
獲取我使用SQL Server 2012 SP1更新
而我應該得到 否0 是1
當前所有三個表的數據
- 投票
- PollOptions
- PollResponse
您可以發佈從每個表的數據? – Taryn
你好,你可以發佈其他2個表的樣子嗎? –