请教各位高手这段SQL的错误在哪里!!!
SELECT * FROM (SELECT 
t1.ProductId,t1.[Name],
t2.billsheetno,--订货单号
t2.billsheetid,--单id
t3.costprice as BuyInPrice,--价格
t3.buyinprice as xsj,
t2.CreatedOn,--入库时间
t4.ConsignorId,--供应商编号
t4.[Name] AS gysname,
t1.MeasurementUnit,--单位
t3.Quantity,--数量
t1.sku,--商品编码
nullif(t3.Quantity,0)*nullif(t3.BuyInPrice,0) AS amount,
nullif(t3.quantity,0)*nullif(t3.costprice,0) as cbje,
t5.ClassId,--课题编号
t5.ClassNumber--课题号
FROM dbo.Product t1 left join dbo.Inventory_Consignor t4 on t1.SupplierId=t4.ConsignorId, dbo.Inventory_BillSheet t2 ,
dbo.Inventory_BillSheet_Item t3 ,dbo.User_Class t5  

WHERE t1.ProductId=t3.ProductId 
AND t2.BillSheetId=t3.BillSheetId 
and t2.billtype=2 and t2.orderstatusid=7
AND t5.ClassId=t2.UserClassId

AND t1.isDurability=1
 AND t2.CreatedOn>=+convert(datetime, '2010-05-01 00:00:00') AND t2.CreatedOn<=+convert(datetime, '2010-12-24 23:59:59')
 UNION ALL 
SELECT '' AS ProductId,
'' AS [Name],
'' AS billsheetno,
'' AS BillSheetId,
'' AS BuyInPrice,
'' AS xsj,
'' AS CreatedOn,--入库时间
'' AS ConsignorId,--供应商编号
t4.[Name]+'(小计)' AS gysname,--供应商名称
'' AS MeasurementUnit,--单位
SUM(t3.Quantity) AS Quantity,
'' AS sku,--商品编码
SUM(nullif(t3.Quantity,0)*nullif(t3.BuyInPrice,0)) AS amount ,
SUM(nullif(t3.quantity,0)*nullif(t3.costprice,0)) as cbje,
'' AS  ClassId,
'' AS  ClassNumber
FROM dbo.Product t1 left join dbo.Inventory_Consignor t4 on t1.SupplierId=t4.ConsignorId, dbo.Inventory_BillSheet t2 ,
dbo.Inventory_BillSheet_Item t3 ,dbo.User_Class t5 

WHERE t1.ProductId=t3.ProductId 
AND t2.BillSheetId=t3.BillSheetId and t2.billtype=2 and t2.orderstatusid=7

AND t5.ClassId=t2.UserClassId
AND t1.isDurability=1 AND t2.CreatedOn>=+convert(datetime, '2010-05-01 00:00:00') AND t2.CreatedOn<=+convert(datetime, '2010-12-24 23:59:59')GROUP BY t4.ConsignorId,t4.[Name],t2.CreatedOn
union all
SELECT 
t1.ProductId,t1.[Name],
t2.billsheetno,--订货单号
t2.billsheetid,--单id
t3.costprice as BuyInPrice,--价格
t3.buyinprice as xsj,
t2.CreatedOn,--入库时间
t4.ConsignorId,--供应商编号
t4.[Name] AS gysname,
t1.MeasurementUnit,--单位
t3.Quantity*-1,--数量
t1.sku,--商品编码
(nullif(t3.Quantity,0)*nullif(t3.BuyInPrice,0))*-1 AS amount,
(nullif(t3.quantity,0)*nullif(t3.costprice,0))*-1 as cbje,
t5.ClassId,--课题编号
t5.ClassNumber--课题号
FROM dbo.Product t1 left join dbo.Inventory_Consignor t4 on t1.SupplierId=t4.ConsignorId, dbo.Inventory_BillSheet t2 ,
dbo.Inventory_BillSheet_Item t3 ,dbo.User_Class t5  

WHERE t1.ProductId=t3.ProductId 
AND t2.BillSheetId=t3.BillSheetId 
and t2.billtype=5 and t2.orderstatusid=7
AND t5.ClassId=t2.UserClassId
AND t1.isDurability=1
 AND t2.CreatedOn>=+convert(datetime, '2010-05-01 00:00:00') AND t2.CreatedOn<=+convert(datetime, '2010-12-24 23:59:59')
UNION ALL
SELECT '' AS ProductId,
'' AS [Name],
'' AS billsheetno,
'' AS BillSheetId,
'' AS BuyInPrice,
'' AS xsj,
'' AS CreatedOn,--入库时间
'' AS ConsignorId,--供应商编号
t4.[Name]+'(小计)' AS gysname,--供应商名称
''  AS MeasurementUnit,--单位
SUM(t3.Quantity*-1) AS Quantity,
'' AS sku,--商品编码
SUM((nullif(t3.Quantity,0)*nullif(t3.BuyInPrice,0))*-1) AS amount ,
SUM((nullif(t3.quantity,0)*nullif(t3.costprice,0))*-1) as cbje,
'' AS  ClassId,
'' AS  ClassNumber
FROM dbo.Product t1 left join dbo.Inventory_Consignor t4 on t1.SupplierId=t4.ConsignorId, dbo.Inventory_BillSheet t2 ,
dbo.Inventory_BillSheet_Item t3 ,dbo.User_Class t5 

WHERE t1.ProductId=t3.ProductId 
AND t2.BillSheetId=t3.BillSheetId and t2.billtype=5 and t2.orderstatusid=7

AND t5.ClassId=t2.UserClassId
AND t1.isDurability=1  AND t2.CreatedOn>=+convert(datetime, '2010-05-01 00:00:00') AND t2.CreatedOn<=+convert(datetime, '2010-12-24 23:59:59') GROUP BY t4.ConsignorId,t4.[Name],t2.CreatedOn) t ORDER BY gysname
消息 8114,级别 16,状态 5,第 1 行
从数据类型 varchar 转换为 numeric 时出错。