select
Period,
[Year],
'' as AccountGroup,
Project,
'' as NaturalCode,
ACCNT_NAME,
'' as CostCenter,
sum(Amount) as Amount
from
vw_Journal_Inquiry
WHERE
(PERIOD BETWEEN '201303' AND '201306')
And (Costcenter IN ('0205','020501','020502'))
group by
[Year],
Period,
Project,
ACCNT_NAME
ORDER BY
[Year],
Period,
Project,
ACCNT_NAME
------解决方案-------------------- where Project 不为空嘛。。。。。。
------解决方案-------------------- select distinct Period,[Year],Project from 表
where 条件 and Project 不为空 ------解决方案-------------------- group by period 分组试试 ------解决方案--------------------
select
Period,
[Year],
'' as AccountGroup,
Project,
'' as NaturalCode,
ACCNT_NAME, --这里是问题
'' as CostCenter,
sum(Amount)over(partition by Project) as Amount
from
vw_Journal_Inquiry
WHERE
(PERIOD BETWEEN '201303' AND '201306')
And (Costcenter IN ('0205','020501','020502'))
ORDER BY
[Year],
Period,
Project,
ACCNT_NAME