Home > database > How to conduct field statistics?
How to conduct field statistics?
Time:10-19
Id name subj score 1 a language 88 2 a math 89 3 b language 89 () A SQL shows: calculate the score field in 89 the number of occurrences of, and in the field most shown below, in () place, and can automatically change according to the records
CodePudding user response:
If not object_id (N 'tempdb for.. # a ') is null Drop table # a Go The create table # a ( Id int, [name] nvarchar (10), Subj nvarchar (10), Score nvarchar (10) ) Go Insert # a Select 1, 'a', 'language', '88' union all Select 2, 'a', 'mathematics',' 89 'union all Select 3, 'b', 'English', '89' Go Select * from # a Go
Select * from # a The union Select 4, 'a', ' ', the count (*) from # where a score=89