SELECT
dbo.inventory.avgcost,
dbo.matusetrans.exchangerate,
dbo.workorder.woeq9,
dbo.workorder.wonum,
( DATEPART(yyyy,dbo.workorder.respondby) ) As modifyyear,
( DATEPART(month,dbo.workorder.respondby) ) As modifymonth,
dbo.valuelist.valdesc
FROM dbo.workorder with (nolock)
left join dbo.valuelist with (nolock) on dbo.workorder.woeq9 = dbo.valuelist.value and dbo.valuelist.listname=\'dept\'
left join dbo.matusetrans with (nolock) on dbo.workorder.wonum = dbo.matusetrans.refwo
left join dbo.inventory with (nolock) on dbo.matusetrans.itemnum = dbo.inventory.itemnum and dbo.matusetrans.storeloc = dbo.inventory.location
and dbo.matusetrans.orgid = dbo.inventory.orgid
WHERE
-- 以下是申请页参数
dbo.inventory.orgid = :mroOrg--
and --工单日期由
and --工单日期至
and --工单类型
and --工单年份
求1月分的金额
Sum( [matusetrans.exchangerate]*[inventory.avgcost]) Where([modifyyear] = cYear And [modifymonth]=1)