select sum(发行金额) from(
select PoolNameFormat,count(cast(ItemValue as decimal(19,4))) as 发行笔数,sum(cast(ItemValue as decimal(19,4))) as 发行金额 from (
select *,
case when PoolName like '%2015%'then 2015
when PoolName like '%2016%'then 2016
when PoolName like '%2017%'then 2017
when PoolName like '%2018%'then 2018
when PoolName like '%2019%'then 2019
else 1990
end as PoolNameFormat
FROM [InvestSuite].[dbo].[PoolStatistics] as ps
inner join [InvestSuite].[dbo].[AssetPool] as ap
on ps.PoolID=ap.ID
where ps.ItemId=N'400' and cast(ps.ItemValue as decimal(19,4))<1000-- between 1000 and 10000
)a
group by PoolNameFormat
)a