1.表Table中有两字段t_date(datetime)和t_money(money) t_date格式为:yyyy-mm-dd --------------------------------------- 现要求对同一个月的t_money进行求和. 并按月份列出记录.--查询语句 select 年月=convert(char(7),date,120),合计=sum(t_money) from table group by convert(char(7),date,120) --2.money型和高级语言中那一种类型兼容?(float) 和decimal/numeric兼容
select year(getdate()) as 年,month(getdate()) as 月,sum(t_money) as 合计 from table group by year(getdate()),month(getdate())
select 周数=datediff(wk,t_date,getdate()),合计=sum(t_money) from table group by datediff(wk,t_date,getdate()),
改正一下我的错误. select year(t_date)as 年,month(t_date) as 月,sum(t_money) as 合计 from table group by year(t_date),month(t_date)
t_date格式为:yyyy-mm-dd
---------------------------------------
现要求对同一个月的t_money进行求和.
并按月份列出记录.--查询语句
select 年月=convert(char(7),date,120),合计=sum(t_money)
from table
group by convert(char(7),date,120)
--2.money型和高级语言中那一种类型兼容?(float)
和decimal/numeric兼容
from table
group by datediff(wk,t_date,getdate()),
select year(t_date)as 年,month(t_date) as 月,sum(t_money) as 合计 from table group by year(t_date),month(t_date)