分享java帶來的快樂

          我喜歡java新東西

          查詢問題的回答正確率


          select x.mytype 題型, x.title 題目內容, x.answer 答案,x.optionnum 選項數,選項A,選項B,選項C,選項D,選項E,選項F, y.totalcount 回答數, y.rightcount 正確數,trunc(y.rightcount*100/y.totalcount,2)||'%' 百分比
            from (select H.id,
                         H.Title,
                         case
                           when H.Type = 1 then
                            '單選題'
                           when H.Type = 2 then
                            '多選題'
                           when H.Type = 3 then
                            '判斷題'
                           when H.Type = 4 then
                            '填空題'
                           when H.Type = 5 then
                            '問答題'
                         end mytype,
                         H.Answer,
                         H.Optionnum,              
                         MAX(DECODE(Q.Orderby, 1, Q.Title, '')) 選項A,
                         MAX(DECODE(Q.Orderby, 2, Q.Title, '')) 選項B,
                         MAX(DECODE(Q.Orderby, 3, Q.Title, '')) 選項C,
                         MAX(DECODE(Q.Orderby, 4, Q.Title, '')) 選項D,
                         MAX(DECODE(Q.Orderby, 5, Q.Title, '')) 選項E,
                         MAX(DECODE(Q.Orderby, 6, Q.Title, '')) 選項F
                    from tbl_lib_question H, tbl_lib_option Q
                   where Q.Questionid = H.id
                     and Q.Questionid in
                         (select B.questionid questionid
                            from tbl_d_answer_examplan A, tbl_d_answer_question B
                           where A.Examplanid = 562
                             and A.Id = B.Answerexamplanid
                           group by B.Questionid)
                   group by H.id, H.Title, H.Type, H.Answer,H.Optionnum
                   order by H.id) X,
                
                 (select M.questionid,
                         M.totalcount,
                         case
                           when N.rightcount is null then
                            0
                           else
                            rightcount
                         end rightcount
                    from (select B.questionid questionid, count(*) totalcount
                            from tbl_d_answer_examplan A, tbl_d_answer_question B
                           where A.Examplanid = 562
                             and A.Id = B.Answerexamplanid
                           group by B.Questionid) M,
                         (select B.questionid questionid, count(*) rightcount
                            from tbl_d_answer_examplan A, tbl_d_answer_question B
                           where A.Examplanid = 562
                             and A.Id = B.Answerexamplanid
                             and B.Score = B.Gainscore
                           group by B.Questionid) N
                 
                   where M.questionid = N.questionid(+)
                 
                   order by questionid) Y

           where X.id = Y.questionid

          posted on 2009-09-28 22:12 強強 閱讀(431) 評論(0)  編輯  收藏 所屬分類: Oracle數據庫

          主站蜘蛛池模板: 长沙县| 德格县| 平谷区| 蓬安县| 沙坪坝区| 洪雅县| 台南县| 嘉荫县| 高陵县| 府谷县| 哈巴河县| 名山县| 梧州市| 龙川县| 临邑县| 溆浦县| 信丰县| 武宁县| 读书| 贺兰县| 黄陵县| 通海县| 蚌埠市| 龙江县| 禄丰县| 依安县| 亚东县| 利辛县| 新河县| 屯昌县| 西丰县| 柳江县| 托里县| 洛阳市| 留坝县| 澄江县| 姚安县| 碌曲县| 乐亭县| 时尚| 柏乡县|