我有两条SQL语句:
select employeeid,sum(amount) from transport_baseinfo where departmentid='102' and statusid!=48 and statusid!=45 and (substring(convert(varchar(10),[stampdate],120),1,7)='2005-10')
group by employeeid
上面这个语句得到的结果:
employeeid 无列名
0001 45
0002 90和select infor_id,0 from hr_userinfo where infor_unitid = 102
and ((infor_status = '在职' and (LEFT(infor_ruzhishijian,7)<= '2005-10')) or (infor_id in (select infor_id from hr_userinfo
where infor_unitid = 102 and ((infor_status = '在职' or (LEFT(infor_lizhishijian, 7) >= '2005-10'))
and (LEFT(infor_ruzhishijian,7)<= '2005-10')))))
上面这个语句得到的结果:
infor_id 无列名
0001 0
0002 0
0003 0
我希望把上面的两个查询语句并在一起但是其第一项个字段相等的话只要其一;
结果即是:
无列名 无列名
0001 45
0002 90
0003 0要如何实现?请教各位,帮帮忙!
select employeeid,sum(amount) from transport_baseinfo where departmentid='102' and statusid!=48 and statusid!=45 and (substring(convert(varchar(10),[stampdate],120),1,7)='2005-10')
group by employeeid
上面这个语句得到的结果:
employeeid 无列名
0001 45
0002 90和select infor_id,0 from hr_userinfo where infor_unitid = 102
and ((infor_status = '在职' and (LEFT(infor_ruzhishijian,7)<= '2005-10')) or (infor_id in (select infor_id from hr_userinfo
where infor_unitid = 102 and ((infor_status = '在职' or (LEFT(infor_lizhishijian, 7) >= '2005-10'))
and (LEFT(infor_ruzhishijian,7)<= '2005-10')))))
上面这个语句得到的结果:
infor_id 无列名
0001 0
0002 0
0003 0
我希望把上面的两个查询语句并在一起但是其第一项个字段相等的话只要其一;
结果即是:
无列名 无列名
0001 45
0002 90
0003 0要如何实现?请教各位,帮帮忙!
解决方案 »
- 关闭JFrame的右上角叉叉,怎么整个程序都关闭了
- 明天就要参加复试了,兄弟们给点建议啊
- 通过输出过滤器用out输出一个页面, 怎么是乱码
- 关于jtable的selectionmodel问题?
- 如何找到java.lang的包?怎么看包中定义的类?
- 35岁之后大家都去做什么了?
- 这段代码的同步总是无法实现,求帮助
- 在jb里装了j3d怎么不好用啊?
- java 与 Access 数据库的连接问题
- 怎么把一个16进制的数用java转换成相对应字符(在线揭贴)
- 实现真正的邮件转发?
- 存在多个窗体时,当最上面的窗体运行时,如何使其他窗体无法捕获焦点,即不可用,当最上面的窗体消失后,下面的窗体才可以获得焦点?
(
select employeeid id,sum(amount) amount from transport_baseinfo where departmentid='102' and statusid!=48 and statusid!=45 and (substring(convert(varchar(10),[stampdate],120),1,7)='2005-10')
group by employeeid
union
select infor_id id,0 amount from hr_userinfo where infor_unitid = 102
and ((infor_status = '在职' and (LEFT(infor_ruzhishijian,7)<= '2005-10')) or (infor_id in (select infor_id from hr_userinfo
where infor_unitid = 102 and ((infor_status = '在职' or (LEFT(infor_lizhishijian, 7) >= '2005-10'))
and (LEFT(infor_ruzhishijian,7)<= '2005-10')))))
)
group by id
这样行不?
(
(select employeeid id,sum(amount) amount from transport_baseinfo where departmentid='102' and statusid!=48 and statusid!=45 and (substring(convert(varchar(10),[stampdate],120),1,7)='2005-10')
group by employeeid)
union
(select infor_id id,0 amount from hr_userinfo where infor_unitid = 102
and ((infor_status = '在职' and (LEFT(infor_ruzhishijian,7)<= '2005-10')) or (infor_id in (select infor_id from hr_userinfo
where infor_unitid = 102 and ((infor_status = '在职' or (LEFT(infor_lizhishijian, 7) >= '2005-10'))
and (LEFT(infor_ruzhishijian,7)<= '2005-10'))))) )
)
group by id
刚才作union操作的两个表没有加括号,现在应该没有问题了吧
出了错误你吧错误贴给我看