隨筆 - 71  文章 - 15  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          因為口渴,上帝創造了水;
          因為黑暗,上帝創造了火;
          因為我需要朋友,所以上帝讓你來到我身邊
          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認證

          linux經典

          OA系統

          Spring在線

          Structs在線

          專家專欄

          企業信息化

          大型設備共享系統

          工作流

          工作流產品

          網上購書

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜


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

          直接在寫sql時做一下數據連結就可以了
          select
          (
          select ? sum (t1.useHours)? from ?Table1?t1? where ?condition1)?hours1,
          (
          select ? sum (t2.useHours)? from ?Table2?t2? where ?condition2)?hours2
          當然也可以參考如下的寫法:
          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★ 閱讀(1635) 評論(0)  編輯  收藏 所屬分類: Hibernate學習
          主站蜘蛛池模板: 肃宁县| 新乐市| 鸡泽县| 潜江市| 西昌市| 河东区| 洞头县| 武冈市| 峨山| 寻甸| 安西县| 新巴尔虎右旗| 永胜县| 工布江达县| 赞皇县| 卓尼县| 福贡县| 日喀则市| 蒙山县| 茌平县| 福安市| 仙居县| 财经| 东乌| 桂阳县| 汾西县| 自贡市| 定州市| 石阡县| 图片| 大田县| 华蓥市| 墨玉县| 松溪县| 新田县| 共和县| 明星| 武安市| 北安市| 福安市| 吴江市|