zoukankan      html  css  js  c++  java
  • 问卷调查统计查询

    1.需求了解,导出一份调查问卷每个选项的所占的百分比与票数

    2.表的介绍:问卷表 Questionnaire

                         题目表 JY_Question 

                         选项表 JY_Option 

                         问卷记录表 JY_PollResult

    select e.Title as '题目' ,d.Title as '选项' ,c.OptionCount as '票数',c.OptionPer as '百分比' from (
           select a.OptionId,COUNT(a.OptionId) as OptionCount, convert(decimal(10,2),COUNT(a.OptionId))/
                     (select COUNT(*) from JY_PollResult
                     where QuestionId in(
                     select top 1 id from JY_Question
                     where Target=9
    ))*100 as OptionPer from JY_PollResult a ,JY_Question b
    where a.QuestionId=b.id
    and b.Target=9
    group by a.OptionId

        ) as c
    join JY_Option d on c.OptionId=d.id
    join JY_Question e on d.questionId=e.id
    order by e.id

  • 相关阅读:
    微微一笑很倾城(1)
    微微一笑很倾城(1)
    陈先生与程太太
    陈先生与程太太
    我在这
    我在这
    曾有一个人,爱我如生命(2)
    曾有一个人,爱我如生命(2)
    周末情妇
    [转载]黄泉嫁衣
  • 原文地址:https://www.cnblogs.com/smalldragon-hyl/p/8005507.html
Copyright © 2011-2022 走看看