Parcourir la source

part one completed

mpierse il y a 5 ans
Parent
révision
0d5baffff4

+ 4
- 0
src/main/java/io/zipcoder/persistenceapp/Person.java Voir le fichier

@@ -0,0 +1,4 @@
1
+package io.zipcoder.persistenceapp;
2
+
3
+public class Person {
4
+}

+ 9
- 0
src/main/java/io/zipcoder/persistenceapp/PersonService.java Voir le fichier

@@ -0,0 +1,9 @@
1
+package io.zipcoder.persistenceapp;
2
+
3
+import org.springframework.stereotype.Service;
4
+
5
+@Service
6
+public class PersonService {
7
+
8
+
9
+}

+ 60
- 0
src/main/resources/script.sql Voir le fichier

@@ -0,0 +1,60 @@
1
+CREATE TABLE MOVIE(ID INT PRIMARY KEY, TITLE VARCHAR(255),
2
+RUNTIME INT, GENRE VARCHAR(255), IMDB_SCORE DOUBLE, RATING VARCHAR(255));
3
+
4
+INSERT INTO MOVIE
5
+VALUES (1, 'Howard the Duck', 110, 'Sci-Fi', 4.6, 'PG');
6
+
7
+INSERT INTO MOVIE
8
+VALUES (2, 'Lavalantula', 83, 'Horror', 4.7, 'TV-14');
9
+
10
+INSERT INTO MOVIE
11
+VALUES (3, 'Starship Troopers', 129, 'Sci-Fi', 7.2, 'PG-13');
12
+
13
+INSERT INTO MOVIE
14
+VALUES (4, 'Waltz With Bashir', 90	, 'Documentary', 8.0, 'R');
15
+
16
+INSERT INTO MOVIE
17
+VALUES (5, 'Spaceballs', 96, 'Comedy', 7.1, 'PG');
18
+
19
+INSERT INTO MOVIE
20
+VALUES (6, 'Monsters Inc.', 92, 'Animation', 8.1, 'G');
21
+
22
+INSERT INTO MOVIE
23
+VALUES (7, 'The Princess Bride.', 100, 'Awesome', 10.0, 'PG');
24
+
25
+INSERT INTO MOVIE
26
+VALUES (8, 'Elf', 95, 'Christmas', 9.5, 'PG');
27
+
28
+Select * FROM MOVIE
29
+Where GENRE = 'Sci-Fi';
30
+
31
+Select * FROM MOVIE
32
+Where IMDB_SCORE > 6.5;
33
+
34
+Select * FROM MOVIE
35
+Where RUNTIME < 100
36
+AND RATING = 'PG'
37
+OR RATING = 'G';
38
+
39
+Select GENRE, AVG(RUNTIME) FROM MOVIE
40
+GROUP BY GENRE;
41
+
42
+UPDATE MOVIE
43
+SET Rating = 'R'
44
+WHERE TITLE = 'Starship Troopers';
45
+
46
+SELECT ID FROM MOVIE
47
+WHERE GENRE = 'Horror'
48
+OR GENRE = 'Documentary';
49
+
50
+Select RATING, AVG(IMDB_SCORE), MAX(IMDB_SCORE), MIN(IMDB_SCORE)
51
+FROM MOVIE
52
+GROUP BY RATING;
53
+
54
+Select RATING, AVG(IMDB_SCORE), MAX(IMDB_SCORE), MIN(IMDB_SCORE)
55
+FROM MOVIE
56
+GROUP BY RATING
57
+HAVING COUNT(*) >1;
58
+
59
+DELETE FROM MOVIE
60
+WHERE RATING = 'R';