In [1]:
use raj
yes
In [2]:
select bcode, bname
from BUILDING
where bname like '%SOUTH%';
bcode bname
CLSO Classroom South Bldg
LIBSO Library South
In [3]:
select cap,layout,type,dept
from room
where bcode = 'CLSO' and rnumber = '206';
cap layout type dept
60 Tablet Armchairs G
Get rnumber of rooms in building with bcode='CLSO'
In [4]:
select rnumber
from room
where bcode = 'CLSO';
rnumber
100
101
103
104
105
106
107
200
201
203
205
206
207
208
209
210
225
226
227
230
234
236
237
243
300
301
303
305
306
307
308
309
310
325
326
327
328
330
334
336
337
343
400
406
407
408
409
410
411
425
426
427
428
430
434
436
437
443
500
501
503
505
506
507
508
509
510
525
526
527
528
530
600
608
609
(8) Get number of rooms in 'CLSO' building (aggregate operations: min,max,count,sum,avg)
In [5]:
select count(rnumber)
from room
where bcode = 'CLSO';
count(rnumber)
75
(9) Get number of rooms for each building
In [9]:
select bcode BUILDING,count(rnumber) "NUM OF ROOMS"
from room
group by bcode;
BUILDING NUM OF ROOMS
25PP 12
ADHOLD 46
ARTS 9
CLSO 75
COE 3
COMMON 1
LANGDL 85
LIBSO 1
NSC 22
PIED 1
PSC 18
SPARKS 39
URBAN 7
In [14]:
select bname BUILDING,count(rnumber) "NUM OF ROOMS"
from room, building
where room.bcode = building.bcode
group by room.bcode;
BUILDING NUM OF ROOMS
25 Park Place 12
Adherhold Learning Center 46
Art & Humanities Bldg 9
Classroom South Bldg 75
College of Education 3
University Commons 1
Langdale Hall 85
Library South 1
Natural Science Center 22
Piedmont Hall 1
Petit Science Building 18
Sparks Hall 39
Urban Life Bldg 7

(13) Get total number of seats in each building

In [15]:
select bcode,sum(cap)
from room
group by bcode;
bcode sum(cap)
25PP 144
ADHOLD 2655
ARTS 341
CLSO 3083
COE 85
COMMON 200
LANGDL 3906
LIBSO 212
NSC 572
PIED 200
PSC 852
SPARKS 1267
URBAN 736