目录:
- 题
- 数据集生成
- 解
题:Count Student Number in Departments
- 测试数据集生成
USE master
GO
IF (EXISTS (SELECT * FROM master.dbo.sysdatabases WHERE name='LeetCode'))
BEGIN
DROP DATABASE LeetCode
SELECT 1 AS 'deleted_LC'
END
GO
CREATE DATABASE LeetCode
GO
USE LeetCode
GO
IF (OBJECT_ID('department', 'U') IS NOT NULL)
BEGIN
DROP TABLE department
SELECT 1 AS 'deleted_dept'
END
GO
CREATE TABLE department
(
dept_id INT,
dept_name VARCHAR(20),
CONSTRAINT PK_dept_id PRIMARY KEY(dept_id)
)
INSERT INTO department
VALUES
(1, 'Engineering'), (2, 'Science'), (3, 'Law'), (4, 'Aa')
GO
IF (EXISTS (SELECT * FR