私はSQLに比較的慣れていないので、これについて助けてください。基本的に、関数が少し遅いため、クエリでいくつかの計算を実行しようとしています。これを改善できますか?
-- Query to retrive ADA from every school
Select Distinct DY,
DATENAME(MM,DT) as 'Month',
CONVERT(nvarchar,DT,101) as 'Date',
(
Select ((@M_stu - (Select Count(SC) from dbo.ATT where sc=1 AND al!='' AND DY=T.DY))/@M_stu)*100
) as 'Merced ADA',
(
Select ((@A_stu - (Select Count(SC) from dbo.ATT where sc=2 AND al!='' AND DY=T.DY))/@A_stu)*100
) as 'Atwater ADA',
(
Select ((@L_stu - (Select Count(SC) from dbo.ATT where sc=3 AND al!='' AND DY=T.DY))/@L_stu)*100
) as 'Livingston ADA',
(
Select ((@B_stu - (Select Count(SC) from dbo.ATT where sc=4 AND al!='' AND DY=T.DY))/@B_stu)*100
) as 'Buhach ADA',
(
Select ((@Y_stu - (Select Count(SC) from dbo.ATT where sc=5 AND al!='' AND DY=T.DY))/@Y_stu)*100
) as 'Yosemite ADA',
(
Select ((@I_stu - (Select Count(SC) from dbo.ATT where sc=6 AND al!='' AND DY=T.DY))/@I_stu)*100
) as 'Independence ADA',
(
Select ((@G_stu - (Select Count(SC) from dbo.ATT where sc=10 AND al!='' AND DY=T.DY))/@G_stu)*100
) as 'Golden Valley ADA',
(
Select ((@S_stu - (Select Count(SC) from dbo.ATT where sc=92 AND al!='' AND DY=T.DY))/@S_stu)*100
) as 'Sequoia ADA'
From dbo.ATT as T
Order by DY ASC