[B]=sum(case when score='B' then 1 else 0 end)
如果score = 'B',计数器加一,得到的结果是有多少条score = 'B'的记录[B]=max(case when score='B' then 1 else 0 end)
如果score = 'B',为1,否则为0,再用max就可以通过最后的结构是否为1来判断是否存在score = 'B'的记录,
如果score = 'B',计数器加一,得到的结果是有多少条score = 'B'的记录[B]=max(case when score='B' then 1 else 0 end)
如果score = 'B',为1,否则为0,再用max就可以通过最后的结构是否为1来判断是否存在score = 'B'的记录,
当score是B时就是1 否则为0
那么sum(case when score='B' then 1 else 0 end) 就是统计当Score为B的个数
如果score这个字段的值为B,[B]就加一,得到的结果是score字段为B的记录和是多少;[B]=max(case when score='B' then 1 else 0 end)
如果score = 'B',为1,否则为0,再用max就可以通过最后的结构是否为1来判断是否存在score = 'B'的记录。