create table employee(
employee_id char(4) not null,
employee_name varchar(100) not null,
salary integer not null,
department_id char(4) not null,
primary key(Employee_id)
);
insert into employee values('0001','Joe','70000','0001');
insert into employee values('0002','Henry','80000','0002');
insert into employee values('0003','Sam','60000','0002');
insert into employee values('0004','Max','50000','0001');
create table department(
department_id char(4) not null,
department_name varchar(100) not null,
primary key(department_id)
);
insert into department values('0001','IT');
insert into department values('0002','Sales');
select employee_name, max(salary) as max_salary from employee
group by department_id
(1)创建表格:
create table seat(id int(11) not null,
student varchar(100) not null,
primary key(id));
-- 插入数据
insert into seat(id,student) values('1','ABBot');
insert into seat(id,student) values('2','Doris');
insert into seat(id,student) values('3','Emerson');
insert into seat(id,student) values('4','Green');
insert into seat(id,student) values('5','Jeames');
SELECT
(CASE
WHEN MOD(id, 2) != 0 AND counts != id THEN id + 1
WHEN MOD(id, 2) != 0 AND counts = id THEN id
ELSE id - 1
END) AS id,
student
FROM
seat,
(SELECT
COUNT(*) AS counts
FROM
seat) AS seat_counts
ORDER BY id ASC;