以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  sql 语句的更改  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=73844)

--  作者:阿福
--  发布时间:2015/8/27 17:02:00
--  sql 语句的更改
Select YEAR(销售_日期) As 日期_年, month(销售_日期) As 日期_月, sum(销售_母猪), sum(销售_公猪), sum(销售_肉猪), sum(补贴项目), sum(其他收入) f rom
(Select 销售_日期, 销售_金额 As 销售_母猪 f rom {母猪基本信息} u nion all
Select 销售_日期, 销售_金额 As 销售_公猪 f rom {公猪信息} u nion all
Select 销售_日期, 销售_金额 As 销售_肉猪 f rom {肉猪信息} u nion all
Select 日期, 金额 As 补贴项目 f rom {补贴项目} u nion all
Select 日期, 金额 As 其他收入 f rom {其他收入})

As a group by year(销售_日期) ,month(销售_日期) order by year(销售_日期) ,month(销售_日期)


老师,我写得呕心沥血了,麻烦你在帮我改一下

--  作者:Hyphen
--  发布时间:2015/8/27 17:15:00
--  

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=73810&authorid=0&page=0&star=2

 

参考14楼