Tennessee Gibbs hace 6 años
padre
commit
b5be82b775
Se han modificado 1 ficheros con 112 adiciones y 0 borrados
  1. 112
    0
      ZCW QUERYPERSONS.SQL

+ 112
- 0
ZCW QUERYPERSONS.SQL Ver fichero

@@ -0,0 +1,112 @@
1
+mysql> SELECT birthday, address FROM people INNER JOIN homes on homes.id=people.id WHERE birthday IS NOT NULL ORDER BY birthday;
2
+
3
++------------+----------------------------------------+
4
+| birthday   | address                                |
5
++------------+----------------------------------------+
6
+| 1955-01-25 | 234 High Street, PA 19159              |
7
+| 1970-02-23 | 36 E. Bayberry Rd.Savannah, GA 31404   |
8
+| 1960-07-06 | 920 Arlington Street Clifton, NJ 07011 |
9
+| 1980-08-31 | 11 Essex Dr.Farmingdale, NY 11735      |
10
++------------+----------------------------------------+
11
+
12
+mysql> SELECT * FROM people LEFT join homes on (people.home_id = homes.id);
13
++----+------------+-----------+----------+------------+---------+------+----------------------------------------+------------+
14
+| id | first_name | last_name | mobile   | birthday   | home_id | id   | address                                | homenumber |
15
++----+------------+-----------+----------+------------+---------+------+----------------------------------------+------------+
16
+|  3 | Noelle     | Johnson   | 333-3333 | 1960-07-06 |       1 |    1 | 36 E. Bayberry Rd.Savannah, GA 31404   | 565-6895   |
17
+|  4 | Thomas     | Smith     | 152-9854 | 1955-01-25 |       1 |    1 | 36 E. Bayberry Rd.Savannah, GA 31404   | 565-6895   |
18
+| 11 | Paul       | Thompson  | NULL     | 1996-05-27 |       1 |    1 | 36 E. Bayberry Rd.Savannah, GA 31404   | 565-6895   |
19
+|  1 | Tony       | Carbral   | 230-4233 | 1970-02-23 |       2 |    2 | 11 Essex Dr.Farmingdale, NY 11735      | 454-4544   |
20
+|  2 | Raj        | Johnson   | 333-3333 | 1980-08-31 |       3 |    3 | 920 Arlington Street Clifton, NJ 07011 | 985-4515   |
21
+|  5 | Jane       | Smith     | 152-9854 | 1987-12-06 |       3 |    3 | 920 Arlington Street Clifton, NJ 07011 | 985-4515   |
22
+|  6 | Doug       | Brown     | 466-6241 | 1954-12-07 |       3 |    3 | 920 Arlington Street Clifton, NJ 07011 | 985-4515   |
23
+|  9 | John       | Smith     | NULL     | 1998-04-07 |       4 |    4 | 234 High Street, PA 19159              | 267-3940   |
24
+|  7 | John       | Smith     | 152-9854 | 1973-01-23 |    NULL | NULL | NULL                                   | NULL       |
25
+|  8 | Otto       | Von Count | 656-6548 | NULL       |    NULL | NULL | NULL                                   | NULL       |
26
+| 12 | Eli        | Kramer    | NULL     | 1984-01-15 |    NULL | NULL | NULL                                   | NULL       |
27
++----+------------+-----------+----------+------------+---------+------+----------------------------------------+------------+
28
+11 rows in set (0.00 sec)
29
+mysql> select genre from movies where genre = 'Sci-Fi';
30
++--------+
31
+| genre  |
32
++--------+
33
+| Sci-Fi |
34
+| Sci-Fi |
35
++--------+
36
+mysql> SELECT IMDB_SCORE FROM MOVIES WHERE imdb_score >= 6.5;
37
++------------+
38
+| IMDB_SCORE |
39
++------------+
40
+|        7.2 |
41
+|        8.0 |
42
+|        7.1 |
43
+|        8.1 |
44
++------------+
45
+
46
+mysql> SELECT TITLE FROM MOVIES WHERE RATING = 'G' OR RATING = 'PG' AND RUNTIME < 100;
47
++---------------+
48
+| TITLE         |
49
++---------------+
50
+| Spaceballs    |
51
+| Monsters_Inc. |
52
+
53
+
54
+
55
+mysql> SELECT GENRE, AVG(RUNTIME) FROM MOVIES WHERE IMDB_SCORE < 7.5  GROUP BY GENRE;
56
++--------+--------------+
57
+| GENRE  | AVG(RUNTIME) |
58
++--------+--------------+
59
+| Comedy |      96.0000 |
60
+| Horror |      83.0000 |
61
+| Sci-Fi |     119.5000 |
62
++--------+--------------+
63
+
64
+mysql> SELECT TITLE, RATING FROM MOVIES;
65
++-------------------+--------+
66
+| TITLE             | RATING |
67
++-------------------+--------+
68
+| Howard the Duck   | PG     |
69
+| Lavalantula       | TV-14  |
70
+| Starship_Troopers | R      |
71
+| Waltz_With_Bashir | R      |
72
+| Spaceballs        | PG     |
73
+| Monsters_Inc.     | G      |
74
++-------------------+--------+
75
+mysql> SELECT ID,RATING FROM MOVIES WHERE GENRE = 'HORROR' OR GENRE = 'DOCUMENTARY';
76
++----+--------+
77
+| ID | RATING |
78
++----+--------+
79
+|  2 | TV-14  |
80
+|  4 | R      |
81
++----+--------+
82
+
83
+mmysql> SELECT RATING, AVG(IMDB_SCORE), MAX(IMDB_SCORE), MIN(IMDB_SCORE) FROM MOVIES GROUP BY RATING;
84
++--------+-----------------+-----------------+-----------------+
85
+| RATING | AVG(IMDB_SCORE) | MAX(IMDB_SCORE) | MIN(IMDB_SCORE) |
86
++--------+-----------------+-----------------+-----------------+
87
+| G      |         8.10000 |             8.1 |             8.1 |
88
+| PG     |         5.85000 |             7.1 |             4.6 |
89
+| R      |         7.60000 |             8.0 |             7.2 |
90
+| TV-14  |         4.70000 |             4.7 |             4.7 |
91
++--------+-----------------+-----------------+-----------------+
92
+
93
+mysql> SELECT RATING, AVG(IMDB_SCORE), MAX(IMDB_SCORE), MIN(IMDB_SCORE) FROM MOVIES GROUP BY RATING HAVING COUNT(*)>1;;
94
++--------+-----------------+-----------------+-----------------+
95
+| RATING | AVG(IMDB_SCORE) | MAX(IMDB_SCORE) | MIN(IMDB_SCORE) |
96
++--------+-----------------+-----------------+-----------------+
97
+| PG     |         5.85000 |             7.1 |             4.6 |
98
+| R      |         7.60000 |             8.0 |             7.2 |
99
++--------+-----------------+-----------------+-----------------+
100
+
101
+mysql> DELETE FROM MOVIES WHERE RATING = 'R';
102
+Query OK, 2 rows affected (0.01 sec)
103
+
104
+mysql> SELECT * FROM MOVIES;
105
++----+-----------------+---------+-----------+------------+--------+
106
+| id | title           | runtime | genre     | imdb_score | rating |
107
++----+-----------------+---------+-----------+------------+--------+
108
+|  1 | Howard the Duck |     110 | Sci-Fi    |        4.6 | PG     |
109
+|  2 | Lavalantula     |      83 | Horror    |        4.7 | TV-14  |
110
+|  5 | Spaceballs      |      96 | Comedy    |        7.1 | PG     |
111
+|  6 | Monsters_Inc.   |      92 | Animation |        8.1 | G      |
112
++----+-----------------+---------+-----------+------------+--------+