分享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 強強 閱讀(426) 評論(0)  編輯  收藏 所屬分類: Oracle數據庫

          主站蜘蛛池模板: 通海县| 宁夏| 始兴县| 淄博市| 中方县| 奇台县| 宣化县| 淮北市| 汝阳县| 平舆县| 平度市| 木兰县| 温宿县| 苍溪县| 台前县| 商都县| 镇坪县| 栾川县| 石林| 桂林市| 松原市| 桐梓县| 太谷县| 堆龙德庆县| 通山县| 梁山县| 札达县| 富裕县| 宿州市| 红安县| 洪雅县| 罗定市| 柳州市| 泌阳县| 湖口县| 大安市| 安图县| 芷江| 昂仁县| 和平县| 湖口县|