if object_id('tempdb: #tempTable') is not NULL Begin Drop Table#tempTableEndSELECT TOP + [Campus],[academic year],[Exam Grade],[Exam Category],avg(language contains challenges)'Average score',STDEV(language contains challenges)'Standard deviation' into#tempTable from [Schoolanalyze].[dbo].[Score Analysis]Group by [Campus],[academic year],[Exam Grade],[Exam Category]Update [Schoolanalyze].[dbo].[Score Analysis]Set [standard points for language with challenges] =([language with challenges] -(SelectAverage score from#tempTablewhereCampus= [Score Analysis]. campus andYear= [Score Analysis]. School year andExam Grade= [Score Analysis]. Exam Grade andExam Category= [Score Analysis]. Test category))/ (SelectStandard deviation from#tempTablewhereCampus= [Score Analysis]. campus andYear= [Score Analysis]. School year andExam Grade= [Score Analysis]. Exam Grade andExam Category= [Score Analysis]. Exam category)Select * from#tempTableif object_id('tempdb: #tempTable') is not NULL Begin Drop Table#tempTableEnd
Find standard sub-SQL