代码又出错了,麻烦老师改一下!
cmd.CommandText = "Select YEAR(年) As 年, sum(收入) as 收入, sum(支出) as 支出 f rom " & _
"(Select 销售_日期 as 年, 销售_金额 as 收入, 0 as 支出 f rom {母猪基本信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 销售_日期 as 年, 销售_金额 as 收入, 0 f rom {公猪信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 销售_日期 as 年, 销售_金额 as 收入, 0 f rom {肉猪信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 金额 as 收入, 0 f rom {补贴项目} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 金额 as 收入, 0 f rom {其他收入} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 购买_日期 as 年, 0, 购买_金额 as 支出 f rom {母猪基本信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 购买_日期 as 年, 0, 购买_金额 as 支出 f rom {公猪信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 购买_日期 as 年, 0, 购买_金额 as 支出 f rom {肉猪信息} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 饲料量_总金额 as 支出 f rom {饲料采购} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 总金额 as 支出 f rom {疫苗采购} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 总金额 as 支出 f rom {药品采购} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 总金额 as 支出 f rom {易耗品采购} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 投保金额 as 支出 f rom {保险费} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 金额 as 支出 f rom {水电费} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 金额 as 支出 f rom {工资费用} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 支出金额 as 支出 f rom {工程折旧费用} where [sys_user]='" & user.Name & "' u nion all " & _
"Select 日期 as 年, 0, 金额 as 支出 f rom {其他支出} where [sys_user]='" & user.Name & "') " & _
"As a group by year(年) order by year(年) "