隨筆 - 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學習
          主站蜘蛛池模板: 琼中| 宣恩县| 盱眙县| 光泽县| 偃师市| 台湾省| 云霄县| 阜平县| 建始县| 隆尧县| 新田县| 枞阳县| 云霄县| 盐城市| 沈阳市| 彩票| 达尔| 陆良县| 屏南县| 丰原市| 元阳县| 福安市| 禄劝| 监利县| 青海省| 桐柏县| 准格尔旗| 石嘴山市| 理塘县| 涞源县| 保靖县| 托克托县| 二手房| 长寿区| 安国市| 友谊县| 丹江口市| 平乐县| 武功县| 同心县| 轮台县|