sql队伍的胜负情况
Posted 金琥
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql队伍的胜负情况相关的知识,希望对你有一定的参考价值。
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 队名
以上是关于sql队伍的胜负情况的主要内容,如果未能解决你的问题,请参考以下文章