insert t_tj
Select convert(char(6),lldate,112),sum(llmoney) from t_ll
where llbm = '生产部'
group by convert(char(6),lldate,112)
Select convert(char(6),lldate,112),sum(llmoney) from t_ll
where llbm = '生产部'
group by convert(char(6),lldate,112)
解决方案 »
- SQLSERVER中如何获得表的中文名称?
- 一个存储过程的问题
- 关于多表查询!!!!!
- 关于设置SQL 邮件的问题!!
- 出现以下错误是怎么回事
- SQL SERVER 如何将*.idx *.dat文件导入到SQL SERVER 数据库中!!!!急!加分加分
- 简单问题
- To xlaser(恍惚苍蝇):谢谢了,你给我的关于RDS和DTS的资料已经收到,不过小弟只能发100分的帖子,实在不好意思!
- 紧急啊:朋友们帮帮忙能不能告诉我为什么我的数据库日志三天就长到8个G?
- liujianjun_(流星尔),谢谢你的建议,请过来领分
- 求教在SQL-7.0中SELECT语句中的字符操作
- 请大家帮忙看看这段ADO程序,多谢!
as
insert t_tj
Select convert(char(6),lldate,112),sum(llmoney) from t_ll
where llbm = @llbm
group by convert(char(6),lldate,112)
go调用:
exec test '生产部'
where llbm = '生产部'
group by convert(char(7),lldate,112)
where llbm = '生产部'
group by convert(char(7),lldate,120)
select convert(char(7),lldate,120) 时间,sum(llmoney) llmoney into 新表 from t_ll
where llbm = '生产部'
group by convert(char(7),lldate,120)
as
insert t_tj
select left(convert(char(10),lldate,102),7) ,sum(llmoney)
from t_ll
where llbm = '生产部'
group by left(convert(char(10),lldate,102),7)
go
select replace(convert(char(7),lldate,120),'-','.') 时间,sum(llmoney) llmoney into 新表 from t_ll
where llbm = '生产部'
group by replace(convert(char(7),lldate,120),'-','.')
@fdate '2003.01'
@tdate '2003.05'
@llbm '生产部'执行后 t_tj 应该是
2003.01 200
2003.02 400
2003.03 0
2003.04 0
2003.05 500我刚开始那个执行后的数据输入错了 因该是这个 各位大侠怎么做?
@tdate 至某年某月
as
insert t_tj
Select convert(char(6),lldate,112),sum(llmoney) from t_ll
where llbm = @llbm and convert(char(6),lldate,112) between @fdate and @tdate
group by convert(char(6),lldate,112)
go调用:
exec test '200301','200305','生产部'
@fdate char(6),@tdate char(6),@llbm varchar(10)
asSelect replace(convert(char(7),a.[date],120),'-','.') 时间,sum(数量) 合计 from (
select dateadd(month,id,@fdate+'.01') [date] from (select (select count(*) from sysobjects where id<a.id) [id] from sysobjects) tem where datediff(month,dateadd(month,id,@fdate+'.01'),@tdate+'.01')>=0) a
left join
(
select * from t_ll where llbm = @llbm and
cast(convert(char(6),lldate,112)+'01' as datetime) between @fdate and @tdate
) b on datediff(month,a.[date],b.lldate)=0
group by replace(convert(char(7),a.[date],120),'-','.')
go调用:
exec test '200301','200305','生产部'