Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.58 KB | None | 0 0
  1. select
  2.      pl.PollID
  3.     ,pl.PollQuestion
  4.     ,pl.PollAnswerAVirtue
  5.     ,pl.PollAnswerBVirtue
  6.     ,sum(aa.AnswerA) as AnswerA
  7.     ,sum(ab.AnswerB) as AnswerB
  8. from PollLog pl (nolock)
  9.     join (select Pollid,count(*) as AnswerA from VoteLog where VoteAnswer='A' group by Pollid) aa
  10.         on pl.PollId=aa.Pollid
  11.     join (select Pollid,count(*) as AnswerB from VoteLog where VoteAnswer='B' group by Pollid) ab
  12.         on pl.PollId=aa.Pollid
  13. where 1=1
  14.     and pl.pollid in (select max(Pollid) from  PollLog)
  15.     and filter='VVASAS'
  16.     and filter in ('A','B')
  17. group by  
  18.      pl.PollID
  19.     ,pl.PollQuestion
  20.     ,pl.PollAnswerAVirtue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement