昨天没人应,今天再问,希望有高手帮忙,谢谢
select
[SH].* ,
[StaClip] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] ),
[StaPoints] =(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] ),
[StaClip_1] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=1),
[StaPoints_1]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=1),
[StaClip_2] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=2),
[StaPoints_2]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=2),
[StaClip_3] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=3),
[StaPoints_3]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=3),
[StaClip_4] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=4),
[StaPoints_4]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=4),
[StaClip_5] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=5),
[StaPoints_5]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=5),
[StaClip_6] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=6),
[StaPoints_6]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=6),
[StaClip_7] =(select count([ID]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=7),
[StaPoints_7]=(select sum([points]) from [SHT_All] where [ID]=[SH].[ID] and [Type]=7)
from [SHTrans] [SH]
[SHTrans] [SHT_All] 都是视图来的
运行结果:
服务器: 消息 4408,级别 16,状态 1,行 1
查询和其中的视图或函数超过了 256 个表的限制。
我应该怎样去优化,谢谢