随笔 - 71  文章 - 15  trackbacks - 0
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

因为口渴,上帝创造了水;
因为黑暗,上帝创造了火;
因为我需要朋友,所以上帝让你来到我身边
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★ 阅读(1614) 评论(0)  编辑  收藏 所属分类: Hibernate学习

只有注册用户登录后才能发表评论。


网站导航: