求sql语句,很急,请各位大侠帮忙!
mssql吧
全部回复
仅看楼主
level 1
sueove 楼主
表a有字段 物品编码sno 物品名称name 规格型号ggxh 数量sl 金额je    购买时间data
怎么用sql 同统计出每个月买的物品的数量 和金额 ?
2009年11月10日 12点11分 1
level 1
sueove 楼主
表a有字段 物品编码sno 物品名称name 规格型号ggxh 数量sl 金额je    购买时间data
怎么用sql 统计出每个月买的物品的数量 和金额 ?
大侠帮帮忙啊, 统计出1-12月各个月的数量,和金额,,,注意按月份统计!
如 sno name   ggxh   一月数量   一月金额   二月数量   二月金额 …………
2009年11月10日 13点11分 2
level 0
select sno, sl, je from a where data in(‘一月份’,‘二月份’...)
2009年11月27日 08点11分 3
level 1
select   sl, je
from a
where data >=to_date('20090101','yyyymmdd)
and data <=to_date('20090131'yyyymmdd)
unition all
2月。。
3月。。
小弟不才,虽麻烦肯定好使。
2010年02月26日 04点02分 4
level 1
SELECT a1.yearormonth ,sum(a1.sl),sum(a1.je) from
(SELECT year(date1)*1000+month(date1) AS yearormonth,* FROM a) AS a1
GROUP BY a1.yearormonth
2015年06月24日 02点06分 5
100
2015年06月24日 02点06分
1