소스 검색

part 1 done

Jennifer Chao 5 년 전
부모
커밋
aa5cfbea8e
1개의 변경된 파일58개의 추가작업 그리고 0개의 파일을 삭제
  1. 58
    0
      src/main/resources/script.sql

+ 58
- 0
src/main/resources/script.sql 파일 보기

@@ -0,0 +1,58 @@
1
+CREATE TABLE MOVIES (
2
+ID INT NOT NULL AUTO_INCREMENT,
3
+Title VARCHAR(255),
4
+Runtime INT,
5
+Genre VARCHAR(255),
6
+IMDB_Score DECIMAL,
7
+Rating VARCHAR(255),
8
+);
9
+
10
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
11
+VALUES ('Howard the Duck', 110, 'Sci-Fi', 4.6, 'PG');
12
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
13
+VALUES ('Lavalantula', 83, 'Horror', 4.7, 'TV-14');
14
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
15
+VALUES ('Starship Troopers', 129, 'Sci-Fi', 7.2, 'PG-13');
16
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
17
+VALUES ('Waltz With Bashir', 90, 'Documentary', 8.0, 'R');
18
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
19
+VALUES ('Spaceballs', 96, 'Comedy', 7.1, 'PG');
20
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
21
+VALUES ('Monsters Inc.', 92, 'Animation', 8.1, 'G');
22
+
23
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
24
+VALUES ('Scott Pilgrim vs. The World', 112, 'Action', 7.5, 'PG-13');
25
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
26
+VALUES ('Kung Fu Panda', 92, 'Animation', 7.6, 'PG');
27
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
28
+VALUES ('Black Mirror: Bandersnatch', 90, 'Drama', 7.7, 'TV-MA');
29
+INSERT INTO MOVIES (TITLE, RUNTIME, GENRE, IMDB_SCORE, RATING)
30
+VALUES ('The Room', 99, 'Drama', 3.7, 'R');
31
+
32
+SELECT Title, Genre FROM MOVIES
33
+WHERE Genre = 'Sci-Fi';
34
+
35
+SELECT Title, IMDB_Score FROM MOVIES
36
+WHERE IMDB_Score >= 6.5;
37
+
38
+SELECT Title, Runtime, Rating FROM MOVIES
39
+WHERE Runtime < 100 AND Rating = 'PG' OR Rating = 'G';
40
+
41
+SELECT Genre, AVG(Runtime) FROM MOVIES
42
+WHERE IMDB_Score < 7.5
43
+GROUP BY Genre;
44
+
45
+UPDATE MOVIES
46
+SET Rating = 'R'
47
+WHERE Title = 'Starship Troopers';
48
+
49
+SELECT ID, Title, Genre, Rating FROM MOVIES
50
+WHERE Genre = 'Horror' OR Genre = 'Documentary';
51
+
52
+SELECT Rating, AVG(IMDB_Score), MAX(IMDB_Score), MIN(IMDB_Score) FROM MOVIES
53
+GROUP BY Rating
54
+HAVING COUNT(*) > 1;
55
+
56
+DELETE FROM Movies
57
+WHERE Rating = 'R';
58
+