隨筆 - 71  文章 - 15  trackbacks - 0
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          因為口渴,上帝創(chuàng)造了水;
          因為黑暗,上帝創(chuàng)造了火;
          因為我需要朋友,所以上帝讓你來到我身邊
          Click for Shaanxi xi'an, Shaanxi Forecast
          ╱◥█◣
            |田|田|
          ╬╬╬╬╬╬╬╬╬╬╬
          If only I have such a house!
          〖總在爬山 所以艱辛〗
          Email:myesjoy@yahoo.com.cn
          NickName:yesjoy
          MSN:myesjoy@hotmail.com
          QQ:150230516

          〖總在尋夢 所以苦痛〗

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          Hibernate在線

          Java友情

          Java認(rèn)證

          linux經(jīng)典

          OA系統(tǒng)

          Spring在線

          Structs在線

          專家專欄

          企業(yè)信息化

          大型設(shè)備共享系統(tǒng)

          工作流

          工作流產(chǎn)品

          網(wǎng)上購書

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜


          1 select ? sum (t1.useHours)? as ?hours1? from ?Table1?t1? where ?condition1
          2 select ? sum (t2.useHours)? as ?hours2? from ?Table2?t2? where ?condition2
          上面兩條語句是在同一個表中根據(jù)不同條件查詢出兩個結(jié)果,比如:
          語句1得到結(jié)果為10
          語句2得到結(jié)果為20
          我現(xiàn)在希望得到下面的結(jié)果:
          hours1?hours2?
          10 ????? 20

          直接在寫sql時做一下數(shù)據(jù)連結(jié)就可以了
          select
          (
          select ? sum (t1.useHours)? from ?Table1?t1? where ?condition1)?hours1,
          (
          select ? sum (t2.useHours)? from ?Table2?t2? where ?condition2)?hours2
          當(dāng)然也可以參考如下的寫法:
          hql?
          = ?" select ? sum ( case ? when ?"? + ?whereSql1? + ?"? then ?(pro.preengageHoursOrSamples + pro.adjustOfHours)? else ? 0 ? end )? as ?a,";
          hql?
          += ?"? sum ( case ? when ?"? + ?whereSql2 + ?"? then ?(pro.preengageHoursOrSamples + pro.adjustOfHours)? else ? 0 ? end )? as ?b,";
          hql?
          += ?"? sum ( case ? when ?"? + ?whereSql3 + ?"? then ?(pro.preengageHoursOrSamples + pro.adjustOfHours)? else ? 0 ? end )? as ?c";
          hql?
          += ?"? from ?PreengageOddPO?pro? where ? 1 = 1 ";
          posted on 2006-10-13 14:56 ★yesjoy★ 閱讀(1629) 評論(0)  編輯  收藏 所屬分類: Hibernate學(xué)習(xí)
          主站蜘蛛池模板: 固安县| 西贡区| 阳原县| 汕尾市| 恭城| 临城县| 乡宁县| 滦南县| 乳源| 西畴县| 临武县| 日照市| 灌南县| 锡林郭勒盟| 潍坊市| 政和县| 黑河市| 隆尧县| 韶关市| 栾城县| 沙洋县| 高平市| 阳谷县| 石柱| 阜宁县| 民权县| 昌都县| 彰武县| 九江县| 西林县| 咸阳市| 阳原县| 罗城| 嘉义市| 林芝县| 德格县| 桐梓县| 诸城市| 太和县| 曲麻莱县| 东方市|