Oracle-07:别名,去重,子查询
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥-------------
依旧提供数据库脚本供操作
create table DEPT
(
deptno NUMBER(2) not null,
dname VARCHAR2(20),
loc VARCHAR2(13)
); alter table DEPT
add constraint PK_DEPT primary key (DEPTNO); create table TEACHER
(
tno NUMBER(4) not null,
tname VARCHAR2(30) not null,
tid CHAR(18),
gendar CHAR(3),
birthdate DATE,
job VARCHAR2(20),
hiredate DATE,
sal NUMBER(7,2),
deptno NUMBER(2),
mgrno NUMBER(4),
comm NUMBER(7,2)
); insert into DEPT (deptno, dname, loc)
values (40, '人力部', '北京海淀');
insert into DEPT (deptno, dname, loc)
values (30, '产品部', '北京海淀');
insert into DEPT (deptno, dname, loc)
values (20, '招生部', '上海虹桥');
insert into DEPT (deptno, dname, loc)
values (10, '研究院', '北京海淀');
insert into DEPT (deptno, dname, loc)
values (50, '系统部', '北京昌平');
commit; insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1002, '赵辉', '110101760609001 ', '男', to_date('09-06-1976', 'dd-mm-yyyy'), '考试专员', to_date('23-05-2006 02:40:40', 'dd-mm-yyyy hh24:mi:ss'), 29370.95, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1003, '杨利乐', '', '女', to_date('25-05-1987', 'dd-mm-yyyy'), '考试专员', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 7134.32, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1004, '王益辉', '', '男', to_date('15-08-1991', 'dd-mm-yyyy'), '营销专员', to_date('16-01-2012 03:12:43', 'dd-mm-yyyy hh24:mi:ss'), 30737.36, 20, null, 2300.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1006, '秦璐璐', '', '女', to_date('14-04-1990', 'dd-mm-yyyy'), '运维工程师', to_date('20-06-2012 00:47:09', 'dd-mm-yyyy hh24:mi:ss'), 9013.25, 10, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1007, '梁改焕', '', '女', to_date('20-11-1969', 'dd-mm-yyyy'), '讲师', to_date('13-06-2006 23:07:02', 'dd-mm-yyyy hh24:mi:ss'), 8664.16, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1008, '冯爱仙', '', '女', to_date('02-04-1968', 'dd-mm-yyyy'), '讲师', to_date('06-06-2006 13:41:50', 'dd-mm-yyyy hh24:mi:ss'), 29936.29, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1009, '秦亚杰', '', '男', to_date('16-12-1963', 'dd-mm-yyyy'), '岗位分析师', to_date('13-07-2005 06:32:30', 'dd-mm-yyyy hh24:mi:ss'), 24991.44, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1010, '刘浩星', '', '男', to_date('28-06-1988', 'dd-mm-yyyy'), '考试专员', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 22645.92, null, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1011, '秦春叶', '', '女', to_date('03-03-1971', 'dd-mm-yyyy'), '网络营销师', to_date('07-07-2007 16:02:04', 'dd-mm-yyyy hh24:mi:ss'), 31653.23, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1012, '陈水花', '', '女', to_date('04-11-1928', 'dd-mm-yyyy'), '考试专员', to_date('29-01-2005 23:21:59', 'dd-mm-yyyy hh24:mi:ss'), 29773.37, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1013, '马付妮', '', '女', to_date('13-06-1958', 'dd-mm-yyyy'), '研发', to_date('17-11-2004 08:54:04', 'dd-mm-yyyy hh24:mi:ss'), 17041.60, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1015, '刘得安', '', '男', to_date('08-10-1952', 'dd-mm-yyyy'), '考试专员', to_date('13-03-2005 23:25:37', 'dd-mm-yyyy hh24:mi:ss'), 30356.99, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1016, '高利芹', '', '女', to_date('27-07-1983', 'dd-mm-yyyy'), '岗位分析师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 25751.36, null, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1017, '刘志刚', '', '男', to_date('16-06-1978', 'dd-mm-yyyy'), '运维工程师', to_date('10-05-2008 13:46:33', 'dd-mm-yyyy hh24:mi:ss'), 22344.73, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1018, '高心立', '', '男', to_date('07-02-1941', 'dd-mm-yyyy'), '网络营销师', to_date('03-03-2005 15:17:07', 'dd-mm-yyyy hh24:mi:ss'), 19981.02, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1019, '徐丽', '11010119790809354X', '男', to_date('09-08-1979', 'dd-mm-yyyy'), '研发', to_date('09-12-2009 18:37:22', 'dd-mm-yyyy hh24:mi:ss'), 10950.33, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1021, '刘志红', '', '男', to_date('28-04-1965', 'dd-mm-yyyy'), '岗位分析师', to_date('20-09-2011 10:51:33', 'dd-mm-yyyy hh24:mi:ss'), 7122.60, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1022, '孔鹏飞', '', '男', to_date('30-03-1986', 'dd-mm-yyyy'), '人力资源师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 7045.28, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1023, '李建坡', '110101731107301 ', '男', to_date('07-11-1973', 'dd-mm-yyyy'), '网络营销师', to_date('04-07-2009 06:28:20', 'dd-mm-yyyy hh24:mi:ss'), 21133.91, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1024, '冯爱敏', '', '女', to_date('18-07-1969', 'dd-mm-yyyy'), '营销专员', to_date('12-09-2005 22:41:06', 'dd-mm-yyyy hh24:mi:ss'), 3360.91, 20, null, 50000.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1025, '薛栓成', '110101400710051 ', '男', to_date('10-07-1940', 'dd-mm-yyyy'), '网络营销师', to_date('03-09-2007 14:55:06', 'dd-mm-yyyy hh24:mi:ss'), 12136.65, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1026, '牛伟伟', '11010119851120602X', '女', to_date('20-11-1985', 'dd-mm-yyyy'), '岗位分析师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 6622.66, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1027, '郭香云', '', '女', to_date('15-10-1960', 'dd-mm-yyyy'), '网络营销师', to_date('03-05-2005 13:01:22', 'dd-mm-yyyy hh24:mi:ss'), 26436.18, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1028, '朱花枝', '', '女', to_date('15-05-1956', 'dd-mm-yyyy'), '研发', to_date('11-09-2007 07:41:01', 'dd-mm-yyyy hh24:mi:ss'), 10095.22, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1029, '李岗', '', '男', to_date('16-05-1965', 'dd-mm-yyyy'), '岗位分析师', to_date('09-11-2007 17:26:38', 'dd-mm-yyyy hh24:mi:ss'), 23928.84, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1030, '李军会', '', '男', to_date('15-06-1977', 'dd-mm-yyyy'), '营销专员', to_date('12-05-2007 19:48:21', 'dd-mm-yyyy hh24:mi:ss'), 3492.19, 20, null, 25000.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1031, '孙龙举', '', '男', to_date('30-08-1989', 'dd-mm-yyyy'), '运维工程师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 4323.84, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1032, '韩朝旭', '', '男', to_date('27-03-1900', 'dd-mm-yyyy'), '人力资源师', to_date('11-09-2010 17:54:30', 'dd-mm-yyyy hh24:mi:ss'), 13740.92, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1033, '孙少光', '', '男', to_date('27-09-1988', 'dd-mm-yyyy'), '网络营销师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 19778.62, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1035, '邓香敏', '', '女', to_date('16-07-1966', 'dd-mm-yyyy'), '人力资源师', to_date('12-04-2007 17:47:14', 'dd-mm-yyyy hh24:mi:ss'), 29463.38, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1037, '霍振方', '', '男', to_date('07-11-1984', 'dd-mm-yyyy'), '讲师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 23731.31, 40, 1087, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1038, '许双鸽', '110101781217004 ', '女', to_date('17-12-1978', 'dd-mm-yyyy'), '网络营销师', to_date('05-09-2007 18:45:00', 'dd-mm-yyyy hh24:mi:ss'), 16512.52, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1040, '张春红', '', '女', to_date('17-06-1978', 'dd-mm-yyyy'), '运维工程师', to_date('21-11-2004 06:52:30', 'dd-mm-yyyy hh24:mi:ss'), 31728.83, 10, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1041, '卢玉莲', '110101510606004 ', '女', to_date('06-06-1951', 'dd-mm-yyyy'), '人力资源师', to_date('30-03-2009 17:05:45', 'dd-mm-yyyy hh24:mi:ss'), 17596.43, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1042, '李军会', '', '男', to_date('15-06-1977', 'dd-mm-yyyy'), '讲师', to_date('13-06-2008 03:24:47', 'dd-mm-yyyy hh24:mi:ss'), 8443.59, 50, 1008, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1043, '朱水娃', '', '男', to_date('03-10-1952', 'dd-mm-yyyy'), '讲师', to_date('11-10-2009 03:40:53', 'dd-mm-yyyy hh24:mi:ss'), 9123.09, 30, 1008, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1045, '高大荣', '', '女', to_date('07-04-1955', 'dd-mm-yyyy'), '考试专员', to_date('07-12-2005 14:56:05', 'dd-mm-yyyy hh24:mi:ss'), 4000.00, 10, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1046, '秦付根', '', '男', to_date('03-01-1953', 'dd-mm-yyyy'), '讲师', to_date('10-12-2004 22:51:51', 'dd-mm-yyyy hh24:mi:ss'), 16420.33, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1047, '樊增妮', '110101410715352 ', '女', to_date('15-07-1941', 'dd-mm-yyyy'), '网络营销师', to_date('02-12-2005 14:41:54', 'dd-mm-yyyy hh24:mi:ss'), 13316.01, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1048, '宋素敏', '11010119720111458X', '女', to_date('11-02-1972', 'dd-mm-yyyy'), '岗位分析师', to_date('26-09-2004 12:15:57', 'dd-mm-yyyy hh24:mi:ss'), 2142.92, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1049, '李记', '', '男', to_date('25-03-1948', 'dd-mm-yyyy'), '网络营销师', to_date('23-03-2006 19:12:45', 'dd-mm-yyyy hh24:mi:ss'), 13866.09, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1050, '秦单风', '', '女', to_date('15-11-1989', 'dd-mm-yyyy'), '考试专员', to_date('21-10-2012 05:31:34', 'dd-mm-yyyy hh24:mi:ss'), 21419.38, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1051, '秦占豪', '', '男', to_date('03-09-1985', 'dd-mm-yyyy'), '讲师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 31564.79, 40, 1087, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1054, '张利娟', '', '女', to_date('17-01-1979', 'dd-mm-yyyy'), '网络营销师', to_date('08-05-2011 22:37:13', 'dd-mm-yyyy hh24:mi:ss'), 7419.99, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1055, '陈向琼', '11010119871010354X', '男', to_date('10-10-1987', 'dd-mm-yyyy'), '讲师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 4000.00, 10, 1087, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1056, '杨晓磊', '', '男', to_date('10-05-1991', 'dd-mm-yyyy'), '研发', to_date('05-04-2012 22:16:05', 'dd-mm-yyyy hh24:mi:ss'), 20812.41, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1057, '黄芳菊', '', '女', to_date('13-11-1966', 'dd-mm-yyyy'), '网络营销师', to_date('04-07-2008 17:36:20', 'dd-mm-yyyy hh24:mi:ss'), 12711.46, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1058, '李红勤', '', '女', to_date('08-09-1972', 'dd-mm-yyyy'), '运维工程师', to_date('01-03-2007 05:57:34', 'dd-mm-yyyy hh24:mi:ss'), 21119.95, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1060, '薛栓成', '110101400710051 ', '男', to_date('10-07-1940', 'dd-mm-yyyy'), '考试专员', to_date('22-08-2007 08:06:47', 'dd-mm-yyyy hh24:mi:ss'), 24544.66, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1061, '高发娃', '', '男', to_date('22-05-1929', 'dd-mm-yyyy'), '运维工程师', to_date('12-12-2004 22:49:04', 'dd-mm-yyyy hh24:mi:ss'), 23458.34, 10, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1062, '李新昌', '', '男', to_date('10-03-1964', 'dd-mm-yyyy'), '研发', to_date('01-04-2011 18:00:33', 'dd-mm-yyyy hh24:mi:ss'), 18605.46, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1065, '赵永刚', '', '男', to_date('31-07-1975', 'dd-mm-yyyy'), '岗位分析师', to_date('05-12-2009 15:00:29', 'dd-mm-yyyy hh24:mi:ss'), 3155.96, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1067, '冯世伟', '', '男', to_date('15-11-1988', 'dd-mm-yyyy'), '讲师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 17854.88, 40, 1087, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1068, '张延付', '', '男', to_date('23-05-1970', 'dd-mm-yyyy'), '岗位分析师', to_date('21-05-2009 10:16:16', 'dd-mm-yyyy hh24:mi:ss'), 24294.43, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1070, '陈粉', '', '女', to_date('20-01-1958', 'dd-mm-yyyy'), '营销专员', to_date('29-06-2011 21:27:04', 'dd-mm-yyyy hh24:mi:ss'), 17708.56, 20, null, 600.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1071, '张根祥', '', '男', to_date('12-12-1944', 'dd-mm-yyyy'), '岗位分析师', to_date('06-10-2006 12:14:34', 'dd-mm-yyyy hh24:mi:ss'), 8802.52, null, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1074, '李秋彩', '', '女', to_date('18-11-1974', 'dd-mm-yyyy'), '考试专员', to_date('09-04-2005 01:11:29', 'dd-mm-yyyy hh24:mi:ss'), 19315.97, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1075, '李建玲', '', '女', to_date('16-10-1981', 'dd-mm-yyyy'), '运维工程师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 9023.25, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1076, '张仙', '110101530824316 ', '女', to_date('24-08-1953', 'dd-mm-yyyy'), '考试专员', to_date('09-05-2011 11:15:29', 'dd-mm-yyyy hh24:mi:ss'), 8654.83, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1077, '朱金典', '', '男', to_date('02-10-1968', 'dd-mm-yyyy'), '营销专员', to_date('11-01-2008 11:13:31', 'dd-mm-yyyy hh24:mi:ss'), 6687.97, 20, null, 2700.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1079, '孙玉环', '', '女', to_date('05-06-1950', 'dd-mm-yyyy'), '考试专员', to_date('17-11-2008 12:48:12', 'dd-mm-yyyy hh24:mi:ss'), 7490.24, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1080, '邢中景', '', '男', to_date('28-08-1982', 'dd-mm-yyyy'), '运维工程师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 24990.57, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1081, '韩巧真', '', '女', to_date('19-04-1984', 'dd-mm-yyyy'), '人力资源师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 9880.26, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1084, '杜巧琴', '', '女', to_date('03-01-1962', 'dd-mm-yyyy'), '岗位分析师', to_date('13-01-2011 16:11:23', 'dd-mm-yyyy hh24:mi:ss'), 21655.36, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1085, '席妞娃', '', '女', to_date('15-01-1946', 'dd-mm-yyyy'), '运维工程师', to_date('15-08-2008 06:36:11', 'dd-mm-yyyy hh24:mi:ss'), 24615.12, 20, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1087, '薛素粉', '', '女', to_date('04-01-1967', 'dd-mm-yyyy'), '讲师', to_date('10-09-2007 06:07:14', 'dd-mm-yyyy hh24:mi:ss'), 12357.56, null, 1008, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1088, '王雪英', '', '女', to_date('26-11-1933', 'dd-mm-yyyy'), '岗位分析师', to_date('18-02-2006 23:37:15', 'dd-mm-yyyy hh24:mi:ss'), 23670.53, 10, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1089, '刘秀菊', '110101530414306 ', '女', to_date('14-04-1953', 'dd-mm-yyyy'), '研发', to_date('11-09-2004 18:17:49', 'dd-mm-yyyy hh24:mi:ss'), 22608.20, null, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1090, '刘芳芳', '', '女', to_date('21-12-1989', 'dd-mm-yyyy'), '网络营销师', to_date('10-10-2012 00:24:11', 'dd-mm-yyyy hh24:mi:ss'), 9749.45, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1091, '郝方方', '', '女', to_date('16-05-1986', 'dd-mm-yyyy'), '运维工程师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 5944.72, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1092, '赵利萍', '', '女', to_date('06-12-1967', 'dd-mm-yyyy'), '岗位分析师', to_date('01-08-2006 17:26:08', 'dd-mm-yyyy hh24:mi:ss'), 4575.09, 30, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1093, '杨联星', '', '男', to_date('28-12-1953', 'dd-mm-yyyy'), '考试专员', to_date('27-10-2009 08:41:47', 'dd-mm-yyyy hh24:mi:ss'), 24545.93, 40, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1094, '冯焕', '', '女', to_date('09-05-1942', 'dd-mm-yyyy'), '运维工程师', to_date('27-09-2010 18:25:55', 'dd-mm-yyyy hh24:mi:ss'), 21391.42, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1096, '杨晓雨', '', '女', to_date('07-10-1989', 'dd-mm-yyyy'), '营销专员', to_date('07-08-2013 05:49:14', 'dd-mm-yyyy hh24:mi:ss'), 4161.31, 20, null, 2322.00); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1097, '柴帅友', '', '男', to_date('25-10-1985', 'dd-mm-yyyy'), '网络营销师', to_date('24-11-2011 16:08:38', 'dd-mm-yyyy hh24:mi:ss'), 7805.94, 50, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1098, '韩国强', '110101621016003 ', '男', to_date('16-10-1962', 'dd-mm-yyyy'), '研发', to_date('01-09-2007 12:30:52', 'dd-mm-yyyy hh24:mi:ss'), 13755.87, null, null, null); insert into TEACHER (TNO, TNAME, TID, GENDAR, BIRTHDATE, JOB, HIREDATE, SAL, DEPTNO, MGRNO, COMM)
values (1099, '王参妮', '11010119490831352X', '女', to_date('31-08-1949', 'dd-mm-yyyy'), '岗位分析师', to_date('11-10-2005 13:17:18', 'dd-mm-yyyy hh24:mi:ss'), 26627.94, 30, null, null); commit;
数据库脚本
--使用别名 mysql中单引双引都可以,但是oracle中只能使用双引号来区别特殊字符
select tname as "姓 名" from teacher
--去重 distinct 关键字必须位于查询字段中的第一个位置
select distinct deptno from teacher
--子查询 查询的结果集作为另一个查询语句的条件,字段或者是表
--查询招生部所有男老师的姓名和薪水
--01.查询招生部对应的部门编号
select deptno from dept where dname='招生部'
--02.查询招生部对应等的所有男老师的姓名和薪水
select tname "姓名",sal "薪水" from teacher
where deptno=(select deptno from dept where dname='招生部')
and gendar='男'
--查询老师姓名和对应的部门名称
select tname "姓名",(select dname from dept where deptno=teacher.deptno) "部门名称"
from teacher
--查询招生部和人力部下,所有老师信息
select * from teacher
where deptno in(select deptno from dept where dname in('招生部','人力部'))
Oracle-07:别名,去重,子查询的更多相关文章
- .Net程序员学用Oracle系列(14):子查询、集合查询
1.子查询 1.1.子查询简介 1.2.WITH 子查询 2.集合查询 2.1.UNION 和 UNION ALL 2.2.MINUS 2.3.INTERSECT 2.4.集合运算与 ORDER BY ...
- Oracle 自连接 / 外连接 / 子查询
--连接查询的三种格式 select ename, deptno,dname from emp natural join dept; select ename, deptno,dname from e ...
- oracle 之 统计函数、子查询、操作符
统计函数 COUNT():查询表中的数据记录 AVG():求出平均值 SUM():求和 MAX():求出最大值 MIN():Q求出最小值 子查询 [单行多列] select * from a wh ...
- Oracle学习(六):子查询
1.知识点:能够对比以下的录屏进行阅读 SQL> --子查询所要解决的问题:问题不能一步求解 SQL> --查询工资比SCOTT高的员工信息 SQL> --(1)使用普通方法 SQL ...
- Oracle系列八 高级子查询
子查询 子查询 (内查询) 在主查询执行之前执行 主查询(外查询)使用子查询的结果 多列子查询 主查询与子查询返回的多个列进行比较 多列子查询中的比较分为两种: 成对比较 问题:查询与141号或174 ...
- MySQL 07章_子查询
子查询就是查询中还可以嵌套其他的查询,通常是内层查询的结果作为外层查询的条件来使用 执行循序,自内向外依次执行 一.内层查询返回“单列单行”的结果 -- 1.查询宋江的出生日期 SELECT TIME ...
- ORACLE 多表连接与子查询
Oracle表连接 SQL/Oracle使用表连接从多个表中查询数据 语法格式: select 字段列表from table1,table2where table1.column1=table2.co ...
- Oracle DB 使用子查询来解决查询
• 定义子查询 • 描述子查询可以解决的问题类型 • 列出子查询的类型 • 编写单行和多行子查询 • 子查询:类型.语法和准则 • 单行子查询: – 子查询中的组函数 – 带有子查询的HAVING ...
- Oracle数据库多表查询,子查询,集合运算
记得自己要敲o~~~ select * from bonus; select * from salgrade; from dual; --笛卡尔积:两张表的乘积 select * from emp,d ...
- SQL语句汇总(三)——聚合函数、分组、子查询及组合查询
聚合函数: SQL中提供的聚合函数可以用来统计.求和.求最值等等. 分类: –COUNT:统计行数量 –SUM:获取单个列的合计值 –AVG:计算某个列的平均值 –MAX:计算列的最大值 –MIN:计 ...
随机推荐
- Obj-C中内存的管理一瞥
注意,ARC仅仅(自动)释放你手工管理的Objective-C类实例的内存, 但是不会释放由C函数或者Core Foundation(Cocoa的底层,C语言的变体)申请的内存.
- 关于MySQL主从复制中UUID的警告信息
日期: 2014年5月23日 博客: 铁锚 最近在查看MariaDB主从复制服务器 Master 的错误日志时看到很多条警告信息,都是提示 UUID()函数不安全,可能 Slave 产生的值和 Mas ...
- OpenCV 直线检测
/*------------------------------------------------------------------------------------------*\ This ...
- javascript中的eval函数
eval()只有一个参数,如果传入的参数不是字符串,则直接返回这个参数.否则会将字符串当成js代码进行编译,如果编译失败则抛出语法错误(SyntaxError)异常.如果编译成功则开始执行这段代码,并 ...
- 解读Raft(三 安全性)
前言 之前的两篇文章更多的是在描述Raft算法的正常流程,没有过多的去讨论异常场景. 而实际在分布式系统中,我们更多的都是在应对网络不可用.机器故障等异常场景,所以本篇来讨论一下Raft协议的安全性, ...
- async & await 异步编程的一点巧方法
await 关键字不会创建新的线程,而是由Task任务或是FCL中的xxxAsync等方法创建的线程,而且这里创建的线程都是基于线程池创建的工作线程,属于后台线程. await关键字会阻塞/暂停调用它 ...
- Asp.NetCore+Microsoft.AspNetCore.SignalR前后端分离
1.新建WebApi 2.安装Microsoft.AspNetCore.SignalR 3.新建一个集线器和消息类 using Microsoft.AspNetCore.SignalR; using ...
- Python list 两个不等长列表交叉合并
遇到一个需求,需要对两个长度不一定相等的列表进行交叉合并.像拉拉链一样(两边的拉链不一定相等). 如: a = [1, 3, 5] b = [2, 4, 6, 8] 需将a, b 合并为 c c = ...
- c#调用野狗云 rest api
野狗云就不多介绍了,这里主要是记录一下c#调用他们提供的rest api,把数据post到野狗云存储,直接上代码 static void Main(string[] args) { string st ...
- Struts2数据传输的背后机制:ValueStack(值栈)
1. 数据传输背后机制:ValueStack(值栈) 在这一切的背后,是因为有了ValueStack(值栈)! ValueStack基础:OGNL 要了解ValueStack,必须先理解OGN ...