У моего преподавателя есть вопросы ниже. 7) Музей запрашивает имена и фамилии всех археологов, а также количество мест, где они обнаружили динозавров Tyrannosaurus Rex.Обратите внимание, что некоторые археологи не нашли никаких динозавров, а некоторые не нашли никаких динозавров Tyrannosaurus Rex, но все же должны быть включены в список.,Может кто-нибудь помочь с тем, как я могу включить всю информацию из вопроса?
SELECT ARCHEOLOGIST.FIRST_NAME, ARCHEOLOGIST.LAST_NAME,DINOSAUR.DINO_NAME, LOCATION.LOCATION_ID,
COUNT(LOCATION.LOCATION_ID)AS TOTAL_LOCATIONS
FROM ARCHEOLOGIST
LEFT OUTER JOIN DISCOVERY ON DISCOVERY.ARCH_ID = ARCHEOLOGIST.ARCH_ID
LEFT OUTER JOIN LOCATION ON LOCATION.LOCATION_ID = DISCOVERY.LOCATION_ID
LEFT OUTER JOIN DINOSAUR ON DISCOVERY.DINO_ID = DINOSAUR.DINO_ID
WHERE (DISCOVERY.DINO_ID = 123)
group by ARCHEOLOGIST.FIRST_NAME, ARCHEOLOGIST.LAST_NAME, DINOSAUR.DINO_NAME, LOCATION.LOCATION_ID;
CREATE TABLE DINOSAUR
(DINO_ID NUMBER(3) PRIMARY KEY,
DINO_NAME VARCHAR2(50) NOT NULL,
DIET_TYPE VARCHAR2(25) NOT NULL,
COST NUMBER(10));
CREATE TABLE LOCATION
(LOCATION_ID VARCHAR2(2) PRIMARY KEY,
LOCATION_NAME VARCHAR2(50) NOT NULL,
STATE_NAME VARCHAR2(50) NOT NULL);
CREATE TABLE ARCHEOLOGIST
(ARCH_ID VARCHAR2(3) PRIMARY KEY,
FIRST_NAME VARCHAR2(25) NOT NULL,
LAST_NAME VARCHAR2(25) NOT NULL);
CREATE TABLE DISCOVERY
(DISC_ID VARCHAR2(3) PRIMARY KEY,
DISC_DATE DATE NOT NULL,
DINO_ID NUMBER(3) NOT NULL,
ARCH_ID VARCHAR2(3) NOT NULL,
LOCATION_ID VARCHAR2(2) NOT NULL);
ALTER TABLE DISCOVERY
ADD CONSTRAINT DINO_ID
FOREIGN KEY (DINO_ID)
REFERENCES DINOSAUR(DINO_ID);
ALTER TABLE DISCOVERY
ADD CONSTRAINT ARCH_ID
FOREIGN KEY (ARCH_ID)
REFERENCES ARCHEOLOGIST(ARCH_ID);
ALTER TABLE DISCOVERY
ADD CONSTRAINT LOCATION_ID
FOREIGN KEY (LOCATION_ID)
REFERENCES LOCATION(LOCATION_ID);
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE, COST)
VALUES
(123,'TYRANNOSAURUS REX','CARNIVORE',100000);
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE, COST)
VALUES
(234,'TYRANNOSAURUS REX','CARNIVORE',500000);
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE, COST)
VALUES
(345,'TYRANNOSAURUS REX','HERBIVORE',250000);
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE)
VALUES
(456,'TYRANNOSAURUS REX','HERBIVORE');
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE, COST)
VALUES
(567,'TYRANNOSAURUS REX','HERBIVORE',500000);
INSERT INTO DINOSAUR
(DINO_ID, DINO_NAME, DIET_TYPE, COST)
VALUES
(789,'TYRANNOSAURUS REX','CARNIVORE',750000);
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('A1','BLACK HILLS','SOUTH DAKOTA');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('B2','LOS ANGELES','CALIFORNIA');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('C3','GRAND CANYON','ARIZONA');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('D4','TAMPA','FLORIDA');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('E5','ROME','NEW YORK');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('F6','CALGARY','CANADA');
INSERT INTO LOCATION
(LOCATION_ID, LOCATION_NAME, STATE_NAME)
VALUES
('G7','MILWAUKEE','WISCONSIN');
INSERT INTO ARCHEOLOGIST
(ARCH_ID,FIRST_NAME,LAST_NAME)
VALUES
('ABC','ERNEST','HEMINGWAY');
INSERT INTO ARCHEOLOGIST
(ARCH_ID,FIRST_NAME,LAST_NAME)
VALUES
('DEF','AYN','RAND');
INSERT INTO ARCHEOLOGIST
(ARCH_ID,FIRST_NAME,LAST_NAME)
VALUES
('GHI','GRETA','GARBO');
INSERT INTO ARCHEOLOGIST
(ARCH_ID,FIRST_NAME,LAST_NAME)
VALUES
('JKL','FRED','ASTAIRE');
INSERT INTO ARCHEOLOGIST
(ARCH_ID,FIRST_NAME,LAST_NAME)
VALUES
('MNO','GINGER','ROGERS');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('Z12',TO_DATE('12/12/2010','MM/DD/YYYY'),123,'ABC','A1');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('A58',TO_DATE('12/15/2011','MM/DD/YYYY'),123,'ABC','C3');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('R47',TO_DATE('07/18/2012','MM/DD/YYYY'),345,'MNO','A1');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('F21',TO_DATE('06/15/2009','MM/DD/YYYY'),456,'JKL','E5');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('B65',TO_DATE('05/10/2011','MM/DD/YYYY'),456,'ABC','F6');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('O99',TO_DATE('08/20/2012','MM/DD/YYYY'),234,'MNO','G7');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('H71',TO_DATE('05/10/2012','MM/DD/YYYY'),567,'ABC','F6');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('B34',TO_DATE('07/25/2010','MM/DD/YYYY'),123,'DEF','D4');
INSERT INTO DISCOVERY
(DISC_ID, DISC_DATE, DINO_ID, ARCH_ID, LOCATION_ID)
VALUES
('K81',TO_DATE('08/01/2016','MM/DD/YYYY'),567,'MNO','B2');