1. Learn
  2. /
  3. 课程
  4. /
  5. SQL Server 中级

Connected

道练习

使用 CASE 创建多个分组

在本练习中,您将编写一个 CASE 语句,根据以下区间将 DurationSeconds 的取值分成 5 组:

DurationSeconds SecondGroup
<= 120 1
> 120 and <= 600 2
> 600 and <= 1200 3
> 1201 and <= 5000 4
For all other values 5

说明

100 XP

创建一个新列 SecondGroup,根据上面的区间,使用 DurationSeconds 列的取值进行分组。