在这个语句中增加你需要的结果好象不行吧,另生成一个结果集倒是可能:select count(*) 记录总数,
SUM(毛重) 毛重总数,
SUM(皮重) 皮重总数,
SUM(净重) 净重总数,
SUM(case when 净重 is null then 1 else 0 end) 未回皮数,
SUM(case when 净重 is null then 0 else 1 end) 已回皮数
from (
select PoundMaterial.vMaterialName 货名,
PoundIntOutUnit.vUnitName 发货方,
ShouHuoFang.vUnitName 收货方,
PoundType.vTypeName 装货方,
Operator.vUserName 称毛重,
ChengPiZhong.vUserName 称皮重,
PoundRecord.vRecoreId 磅单号,
PoundRecord.vCarNo 车号,
PoundRecord.SkinDate 毛重日期,
PoundRecord.SkinTime 毛重时间,
PoundRecord.dDate 皮重日期,
PoundRecord.dTime 皮重时间,
PoundRecord.nGrossWei 毛重,
PoundRecord.nSkin 皮重,
PoundRecord.nNetWei 净重
from Operator right join (PoundMaterial right join (PoundType right join (PoundIntOutUnit right join (PoundIntOutUnit ShouHuoFang right join (Operator ChengPiZhong right join PoundRecord on ChengPiZhong.vUserId=PoundRecord.vSkinOperator) on ShouHuoFang.vUnitId=PoundRecord.vInUnitId) on PoundIntOutUnit.vUnitId=PoundRecord.vOutUnitId) on PoundType.vMatTypeId=PoundRecord.vMatTypeId) on PoundMaterial.vMaterialId=PoundRecord.vMaterialId) on Operator.vUserId=PoundRecord.vEmployeeId
where PoundRecord.SkinDate='2005-10-31'
order by PoundRecord.vRecoreId) a
SUM(毛重) 毛重总数,
SUM(皮重) 皮重总数,
SUM(净重) 净重总数,
SUM(case when 净重 is null then 1 else 0 end) 未回皮数,
SUM(case when 净重 is null then 0 else 1 end) 已回皮数
from (
select PoundMaterial.vMaterialName 货名,
PoundIntOutUnit.vUnitName 发货方,
ShouHuoFang.vUnitName 收货方,
PoundType.vTypeName 装货方,
Operator.vUserName 称毛重,
ChengPiZhong.vUserName 称皮重,
PoundRecord.vRecoreId 磅单号,
PoundRecord.vCarNo 车号,
PoundRecord.SkinDate 毛重日期,
PoundRecord.SkinTime 毛重时间,
PoundRecord.dDate 皮重日期,
PoundRecord.dTime 皮重时间,
PoundRecord.nGrossWei 毛重,
PoundRecord.nSkin 皮重,
PoundRecord.nNetWei 净重
from Operator right join (PoundMaterial right join (PoundType right join (PoundIntOutUnit right join (PoundIntOutUnit ShouHuoFang right join (Operator ChengPiZhong right join PoundRecord on ChengPiZhong.vUserId=PoundRecord.vSkinOperator) on ShouHuoFang.vUnitId=PoundRecord.vInUnitId) on PoundIntOutUnit.vUnitId=PoundRecord.vOutUnitId) on PoundType.vMatTypeId=PoundRecord.vMatTypeId) on PoundMaterial.vMaterialId=PoundRecord.vMaterialId) on Operator.vUserId=PoundRecord.vEmployeeId
where PoundRecord.SkinDate='2005-10-31'
order by PoundRecord.vRecoreId) a
解决方案 »
- 新到公司,用友数据库的数据没了,大家帮我出出主意
- SQLServer2000里有个数据库的互换性6.5的,直接把他选成8.0,会有什么影响吗?
- 我装了SQLSERVER服务器,但运行一段时间后,内存使用达300多M,why?
- sql 函数返回值内容大于8000
- 这个excel插入数据库报错,求教!
- 请介绍写存储过程的好书,需要大量实用例子的
- 誰幫我查一個小触发器的錯誤,謝謝.....
- 菜鸟级问题,求SQL语句
- ASP调用SQL SERVER数据库的难题。
- 求大神帮忙如何实时将一台服务器上sql表插入另一台服务器sql表
- T-SQL中有类似on error resume的语句吗?(关于触发器中语句出错)
- 请问如何将ReadText读取的值赋给一个字符变量
PoundIntOutUnit.vUnitName 发货方,
ShouHuoFang.vUnitName 收货方,
PoundType.vTypeName 装货方,
Operator.vUserName 称毛重,
ChengPiZhong.vUserName 称皮重,
PoundRecord.vRecoreId 磅单号,
PoundRecord.vCarNo 车号,
PoundRecord.SkinDate 毛重日期,
PoundRecord.SkinTime 毛重时间,
PoundRecord.dDate 皮重日期,
PoundRecord.dTime 皮重时间,
PoundRecord.nGrossWei 毛重,
PoundRecord.nSkin 皮重,
PoundRecord.nNetWei 净重,
COUNT(PoundRecord.nGrossWei) 记录总数,
SUM(PoundRecord.nGrossWei) 毛重总数,
SUM(PoundRecord.nSkin) 皮重总数,
SUM(PoundRecord.nNetWei) 净重总数,
SUM(case when PoundRecord.nSkin is null then 1 else 0 end) 未回皮数,
SUM(case when PoundRecord.nSkin is null then 0 else 1 end) 已回皮数
from Operator right join (PoundMaterial right join (PoundType right join (PoundIntOutUnit right join (PoundIntOutUnit ShouHuoFang right join (Operator ChengPiZhong right join PoundRecord on ChengPiZhong.vUserId=PoundRecord.vSkinOperator) on ShouHuoFang.vUnitId=PoundRecord.vInUnitId) on PoundIntOutUnit.vUnitId=PoundRecord.vOutUnitId) on PoundType.vMatTypeId=PoundRecord.vMatTypeId) on PoundMaterial.vMaterialId=PoundRecord.vMaterialId) on Operator.vUserId=PoundRecord.vEmployeeId
where PoundRecord.SkinDate='2005-10-31'
order by PoundRecord.vRecoreId
列 'PoundMaterial.vMaterialName' 在选择列表中无效,因为该列未包含在聚合函数中,并且没有 GROUP BY 子句。所有列都这样!
SUM(毛重) 毛重总数,
SUM(皮重) 皮重总数,
SUM(净重) 净重总数,
SUM(case when 净重 is null then 1 else 0 end) 未回皮数,
SUM(case when 净重 is null then 0 else 1 end) 已回皮数
from (
select PoundMaterial.vMaterialName 货名,
PoundIntOutUnit.vUnitName 发货方,
ShouHuoFang.vUnitName 收货方,
PoundType.vTypeName 装货方,
Operator.vUserName 称毛重,
ChengPiZhong.vUserName 称皮重,
PoundRecord.vRecoreId 磅单号,
PoundRecord.vCarNo 车号,
PoundRecord.SkinDate 毛重日期,
PoundRecord.SkinTime 毛重时间,
PoundRecord.dDate 皮重日期,
PoundRecord.dTime 皮重时间,
PoundRecord.nGrossWei 毛重,
PoundRecord.nSkin 皮重,
PoundRecord.nNetWei 净重
from Operator right join (PoundMaterial right join (PoundType right join (PoundIntOutUnit right join (PoundIntOutUnit ShouHuoFang right join (Operator ChengPiZhong right join PoundRecord on ChengPiZhong.vUserId=PoundRecord.vSkinOperator) on ShouHuoFang.vUnitId=PoundRecord.vInUnitId) on PoundIntOutUnit.vUnitId=PoundRecord.vOutUnitId) on PoundType.vMatTypeId=PoundRecord.vMatTypeId) on PoundMaterial.vMaterialId=PoundRecord.vMaterialId) on Operator.vUserId=PoundRecord.vEmployeeId
where PoundRecord.SkinDate='2005-10-31') a