请教两问题,select into 和 group by-CSDN论坛
1个回答
展开全部
create table Teacher
(
DepartmentID int ,
TeacherID int ,
TeacherName varchar(100)
)
DELETE Department
insert into Department
select 1, 'AAA' union all
select 2,'BBB' union all
select 3, 'CCC'
insert into Teacher
select 1,101,'WACKY' UNION ALL
SELECT 1,102,'XIAOWANG' UNION ALL
SELECT 2,201,'WIXAOZHANG' UNION ALL
SELECT 3,301,'JACKY' UNION ALL
SELECT 3,302,'ANDY' UNION ALL
SELECT 3,303,'JAKY'
select DepartmentName 部门名,count(TeacherID) 教师数 into newtable
from Department d,Teacher t
where d.DepartmentID=t.DepartmentID
group by D.DepartmentName
(
DepartmentID int ,
TeacherID int ,
TeacherName varchar(100)
)
DELETE Department
insert into Department
select 1, 'AAA' union all
select 2,'BBB' union all
select 3, 'CCC'
insert into Teacher
select 1,101,'WACKY' UNION ALL
SELECT 1,102,'XIAOWANG' UNION ALL
SELECT 2,201,'WIXAOZHANG' UNION ALL
SELECT 3,301,'JACKY' UNION ALL
SELECT 3,302,'ANDY' UNION ALL
SELECT 3,303,'JAKY'
select DepartmentName 部门名,count(TeacherID) 教师数 into newtable
from Department d,Teacher t
where d.DepartmentID=t.DepartmentID
group by D.DepartmentName
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询