发布网友 发布时间:2022-04-25 05:41
共2个回答
热心网友 时间:2022-04-10 06:00
创建表:
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[stuscore]
( [name] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[subject] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[score] [int] NULL,
[stuid] [int] NULL)
ON [PRIMARY]
GO
SET ANSI_PADDING OFF
插入数据:
insert into dbo.stuscore values ('张三','数学',,1);
insert into dbo.stuscore values ('张三','语文',80,1);
insert into dbo.stuscore values ('张三','英语',70,1);
insert into dbo.stuscore values ('李四','数学',90,2);
insert into dbo.stuscore values ('李四','语文',70,2);
insert into dbo.stuscore values ('李四','英语',80,2);
查询结果如下:
列出各门课程的平均成绩:
select subject,AVG(score)平均成绩 from stuscore
group by subject;
热心网友 时间:2022-04-10 07:18
select 科目 ,avg(成绩) from 课程
group by 科目
order by agv(成绩)