1.数据显示情况
2.sql语句执行情况
USE [数据库名] GO /****** Object: Table [dbo].[测试] Script Date: 08/03/2017 10:58:02 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[测试]( [编号] [int] IDENTITY(1,1) NOT NULL, [日期] [datetime] NULL, [队名] [nvarchar](50) NULL, [结果] [nvarchar](50) NULL, CONSTRAINT [PK_测试] PRIMARY KEY CLUSTERED ( [编号] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ---如果胜的数量大于5请将此队的排名标记为冠军团队,否则标记为亚军团队 select 队名,(select COUNT(*) from 测试 a where 结果 = '胜' and a.队名 = b.队名) as 胜利次数, (case when (select COUNT(*) from 测试 a where 结果 = '胜' and a.队名 = b.队名) > 5 then '冠军团队' else '亚军团队' end) as 荣誉 from 测试 b group by 队名