1:
select sum(fm_money) as fm_money
from (
select fm_money from t1
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
union all
select fm_money from t2
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
union all
select fm_money from t3
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
) as x2:
select sum(fm_money) as fm_money
from (
select fm_money from t1
where datepart(month,fd_date)=4
union all
select fm_money from t2
where datepart(month,fd_date)=4
union all
select fm_money from t3
where datepart(month,fd_date)=4
) as x
select sum(fm_money) as fm_money
from (
select fm_money from t1
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
union all
select fm_money from t2
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
union all
select fm_money from t3
where fd_date>='2003-4-24'
and fd_date<'2003-4-25'
) as x2:
select sum(fm_money) as fm_money
from (
select fm_money from t1
where datepart(month,fd_date)=4
union all
select fm_money from t2
where datepart(month,fd_date)=4
union all
select fm_money from t3
where datepart(month,fd_date)=4
) as x
解决方案 »
- 老问题,not exists和not in区别 google半天也没明白
- SQL语句问题
- 关于用户收藏表的问题
- 为什么查询得到视图却查不了表?
- 请高手帮我解释一下这条SQL的效率?
- 再发一帖:执行exec后怎么跳出while循环了?
- 急……师哥师姐快来帮个忙——如何安装SQL Server2000
- 有关数据显示的问题。急~~~~!
- 如何在SQL中声明一个数组变量以及相关SQL语句应该怎么写?
- 关于数据库中数据转移问题!在线等,分不够还可以加!急
- 我要向数据库里存一篇2.5万中文字的文章,我应该选择什么字段类型?
- 如何用编程方式备份/恢复或者是导出/导入数据库中的某些表(注意不是所有的表)!!该如何书写语句?
select (select sum(fm_money) from t1 where datediff(day,fd_date,'2003-4-24')=0)+(select sum(fm_money) from t2 where datediff(day,fd_date,'2003-4-24')=0)+(select sum(fm_money) from t3 where datediff(day,fd_date,'2003-4-24')=0) 总和2、
select (select sum(fm_money) from t1 where datediff(month,fd_date,'2003-4-24')=0)+(select sum(fm_money) from t2 where datediff(month,fd_date,'2003-4-24')=0)+(select sum(fm_money) from t3 where datediff(month,fd_date,'2003-4-24')=0) 总和