分享java帶來的快樂

          我喜歡java新東西

          查詢問題的回答正確率


          select x.mytype 題型, x.title 題目內(nèi)容, x.answer 答案,x.optionnum 選項數(shù),選項A,選項B,選項C,選項D,選項E,選項F, y.totalcount 回答數(shù), y.rightcount 正確數(shù),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數(shù)據(jù)庫

          主站蜘蛛池模板: 泰和县| 汝南县| 平度市| 宁城县| 进贤县| 扎囊县| 山西省| 河西区| 陵川县| 碌曲县| 凤冈县| 平谷区| 临江市| 河东区| 土默特右旗| 乐业县| 定远县| 通海县| 读书| 玉溪市| 马公市| 尚志市| 襄垣县| 张家口市| 平陆县| 顺昌县| 新化县| 安丘市| 东海县| 滨州市| 丽江市| 金平| 桑日县| 华阴市| 宿松县| 西藏| 循化| 清原| 寻乌县| 获嘉县| 蚌埠市|