Repository navigation
Expand file tree
/
Copy pathywen58outputscript3.txt
More file actions
190 lines (164 loc) · 4.76 KB
/
Copy pathywen58outputscript3.txt
File metadata and controls
190 lines (164 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Warning: Using a password on the command line interface can be insecure.
--------------
SELECT lastname FROM patient
--------------
+----------+
| lastname |
+----------+
| NULL |
| Gellar |
| Brown |
| Green |
| Gellar |
| Gellar |
| Bing |
| Wen |
+----------+
8 rows in set (0.00 sec)
--------------
SELECT DISTINCT lastname FROM patient
--------------
+----------+
| lastname |
+----------+
| NULL |
| Gellar |
| Brown |
| Green |
| Bing |
| Wen |
+----------+
6 rows in set (0.00 sec)
--------------
SELECT * FROM doctor ORDER BY lastname
--------------
+-----------+------------+---------+-------------+--------------+--------------+
| firstname | lastname | license | licensedate | specialty | hospitalcode |
+-----------+------------+---------+-------------+--------------+--------------+
| Colleen | Aziz | SE66 | 1989-08-24 | Surgeon | ABC |
| Ross | Clooney | HT45 | 1987-06-20 | Surgeon | DDE |
| Bernie | Kavorikian | RD34 | 1980-09-09 | Urologist | BBC |
| Joey | Shabado | GD56 | 1960-06-24 | Podiatrist | BBC |
| Ben | Spock | YT67 | 1955-02-20 | Pediatrician | DDE |
| Doctor | Strange | MV01 | 2016-11-04 | Avengers | ABC |
| Mandy | Webster | JK78 | 1990-08-08 | Surgeon | BBC |
+-----------+------------+---------+-------------+--------------+--------------+
7 rows in set (0.00 sec)
--------------
SELECT name,code FROM hospital WHERE numberofbeds > 1500
--------------
+----------+------+
| name | code |
+----------+------+
| Victoria | ABC |
+----------+------+
1 row in set (0.00 sec)
--------------
SELECT lastname,firstname FROM doctor,hospital
WHERE doctor.hospitalcode = hospital.code
AND hospital.name = 'St.Joseph'
--------------
+------------+-----------+
| lastname | firstname |
+------------+-----------+
| Shabado | Joey |
| Webster | Mandy |
| Kavorikian | Bernie |
+------------+-----------+
3 rows in set (0.00 sec)
--------------
SELECT firstname,lastname FROM patient WHERE lastname LIKE 'G%'
--------------
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| Bill | Gellar |
| Jon | Green |
| Colleen | Gellar |
| Sean | Gellar |
+-----------+----------+
4 rows in set (0.00 sec)
--------------
SELECT patient.firstname,patient.lastname FROM patient,treat,doctor
WHERE patient.OHIP = treat.OHIP AND treat.license = doctor.license
AND doctor.lastname = 'Clooney'
--------------
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| Sean | Gellar |
| Jon | Green |
| Scotty | Bing |
| Suzi | Brown |
+-----------+----------+
4 rows in set (0.00 sec)
--------------
SELECT name,city,lastname FROM hospital,doctor
WHERE hospital.head = doctor.license
--------------
+-----------+----------+----------+
| name | city | lastname |
+-----------+----------+----------+
| Victoria | London | Aziz |
| St.Joseph | London | Shabado |
| Victoria | Victoria | Spock |
+-----------+----------+----------+
3 rows in set (0.00 sec)
--------------
SELECT SUM(numberofbeds) AS "Total Number of Beds" FROM hospital
--------------
+----------------------+
| Total Number of Beds |
+----------------------+
| 3800 |
+----------------------+
1 row in set (0.00 sec)
--------------
SELECT patient.firstname,doctor.firstname FROM patient,doctor,hospital,treat
WHERE patient.OHIP = treat.OHIP AND treat.license = doctor.license
AND doctor.license = hospital.head
--------------
+-----------+-----------+
| firstname | firstname |
+-----------+-----------+
| Bill | Joey |
| Colleen | Joey |
| Scotty | Joey |
| Jon | Colleen |
+-----------+-----------+
4 rows in set (0.00 sec)
--------------
SELECT lastname,firstname FROM doctor,hospital
WHERE doctor.specialty = 'Surgeon' AND doctor.hospitalcode = hospital.code
AND hospital.name = 'Victoria'
--------------
+----------+-----------+
| lastname | firstname |
+----------+-----------+
| Clooney | Ross |
| Aziz | Colleen |
+----------+-----------+
2 rows in set (0.00 sec)
--------------
SELECT firstname FROM doctor WHERE license NOT IN (SELECT license FROM treat)
--------------
+-----------+
| firstname |
+-----------+
| Bernie |
| Ben |
+-----------+
2 rows in set (0.00 sec)
--------------
SELECT firstname,lastname FROM doctor WHERE license
IN (SELECT license FROM treat GROUP BY license HAVING count(OHIP) > 1)
--------------
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| Joey | Shabado |
| Ross | Clooney |
| Mandy | Webster |
+-----------+----------+
3 rows in set (0.00 sec)
Bye