日期:2014-05-17 浏览次数:20563 次
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-10-12 09:05:09
-- Version:
-- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64)
-- Jun 10 2013 20:09:10
-- Copyright (c) Microsoft Corporation
-- Enterprise Evaluation Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------
--> 测试数据:[a]
if object_id('[a]') is not null drop table [a]
go
create table [a]([学校] varchar(4),[姓名] varchar(4),[科目] varchar(4),[成绩] int,[审核] varchar(2))
insert [a]
select '一中','小明','语文',88,'是' union all
select '一中','小黄','英语',89,'是' union all
select '一中','小黄','英语',89,'是' union all
select '一中','小明','化学',99,'是' union all
select '一中','小明','数学',100,'否' union all
select '二中','小李','英语',100,'是' union all
select '一中','小黄','语文',87,'是'
--------------开始查询--------------------------
select 学校,姓名,SUM( 成绩 )成绩
from [a]
WHERE 审核='是' AND NOT EXISTS (
SELEC