17. 391 Rafael A.,Torres
392 V.,Saliternan
393 Melvin,Martin
STUDENT_ID Student_ Name
---------- ---------------------------------------------------
394 Vera,Wetcel
396 James E.,Norman
397 Margaret,Lloyd
399 Jerry,Abdou
268 rows selected.
create index crse_description_i on course(upper(description));
Index created.
selectcourse_no, description from course where upper(description) =
'INTRO TO SQL';
COURSE_NO DESCRIPTION
---------- --------------------------------------------------
204 Intro to SQL
CREATE INDEX CRSE_DESCRIPTION_1 ON COURSE(DESCRIPTION);
Index created.
DROP INDEX CRSE_DESCRIPTION_1 ;
Index dropped.
/*creates the index for the primary key by using the name specified
instead of system issued name*/
CREATE TABLE "books"
(book_id number(11) primary key
using index(create index book_id_ix on "books"(book_id)),
title varchar2(40));
Table created.
select salutation as salutation, substr(phone, 1, 3) as "Area Code",
to_char(registration_date, 'Mon') "Reg.Month",
count (*)
from student
wheresubstr(phone, 1,3) in ('201', '212', '718')
18. and salutation in ('Mr.','Ms.')
group by rollup(salutation, substr(phone, 1,3),
to_char(registration_date, 'Mon'));
SALUT Are RegCOUNT(*)
----- --- --- ----------
Mr. 201 Feb 34
Mr. 201 Jan 9
Mr. 201 43
Mr. 212 Feb 1
Mr. 212 Jan 1
Mr. 212 2
Mr. 718 Feb 72
Mr. 718 Jan 17
Mr. 718 89
Mr. 134
Ms. 201 Feb 27
SALUT Are RegCOUNT(*)
----- --- --- ----------
Ms. 201 Jan 5
Ms. 201 32
Ms. 212 Feb 2
Ms. 212 Jan 1
Ms. 212 3
Ms. 718 Feb 52
Ms. 718 Jan 13
Ms. 718 65
Ms. 100
234
21 rows selected.
select salutation as salutation,
substr(phone, 1, 3) as "Area Code",
to_char(registration_date, 'Mon') "Reg.Month",
count (*)
from student
wheresubstr(phone, 1,3) in ('201', '212', '718')
and salutation in ('Mr.','Ms.')
group by cube(salutation,
substr(phone, 1,3), to_char(registration_date, 'Mon'));
SALUT Are RegCOUNT(*)
----- --- --- ----------
234
Feb 188
Jan 46
201 75
201 Feb 61
201 Jan 14
212 5
19. 212 Feb 3
212 Jan 2
718 154
718 Feb 124
SALUT Are RegCOUNT(*)
----- --- --- ----------
718 Jan 30
Mr. 134
Mr. Feb 107
Mr. Jan 27
Mr. 201 43
Mr. 201 Feb 34
Mr. 201 Jan 9
Mr. 212 2
Mr. 212 Feb 1
Mr. 212 Jan 1
Mr. 718 89
SALUT Are RegCOUNT(*)
----- --- --- ----------
Mr. 718 Feb 72
Mr. 718 Jan 17
Ms. 100
Ms. Feb 81
Ms. Jan 19
Ms. 201 32
Ms. 201 Feb 27
Ms. 201 Jan 5
Ms. 212 3
Ms. 212 Feb 2
Ms. 212 Jan 1
SALUT Are RegCOUNT(*)
----- --- --- ----------
Ms. 718 65
Ms. 718 Feb 52
Ms. 718 Jan 13
36 rows selected.
select salutation as salutation,
substr(phone, 1, 3) as "Area Code",
to_char(registration_date, 'Mon') "Reg.Month",
count (*)
from student
wheresubstr(phone, 1,3) in ('201', '212', '718')
and salutation in ('Mr.','Ms.')
group by
Grouping sets
( (salutation,substr(phone, 1,3)),
( salutation, to_char(registration_date, 'Mon')),
20. ()
);
SALUT Are RegCOUNT(*)
----- --- --- ----------
Ms. 201 32
Mr. 718 89
Ms. 718 65
Mr. 201 43
Mr. 212 2
Ms. 212 3
Mr. Feb 107
Mr. Jan 27
Ms. Feb 81
Ms. Jan 19
234
11 rows selected.
select salutation as salutation,
substr(phone, 1, 3) ,
count (*)
from student
wheresubstr(phone, 1,3) in ('201', '212', '718')
and salutation in ('Mr.','Ms.')
group by salutation,substr(phone, 1,3);
SALUT SUB COUNT(*)
----- --- ----------
Ms. 201 32
Mr. 718 89
Ms. 718 65
Mr. 201 43
Mr. 212 2
Ms. 212 3
6 rows selected.
select salutation as salutation,
2 to_char(registration_date, 'Mon') ,
3 count (*)
4 from student
5 wheresubstr(phone, 1,3) in ('201', '212', '718')
6 and salutation in ('Mr.','Ms.')
7 group by salutation,to_char(registration_date, 'Mon');
SALUT TO_ COUNT(*)
----- --- ----------
Mr. Feb 107
Ms. Feb 81
Ms. Jan 19
21. Mr. Jan 2
selects.student_id, s.First_name||','||s.last_name as Student, count
(e.student_id)
from student s inner join enrollment e
ons.student_id = e.student_id
having count(e.student_id) =( select max (count (*))
from enrollment
group by student_id )
group by s.first_name, s.last_name, s.student_id, e.student_id ;
STUDENT_ID STUDENT
---------- ---------------------------------------------------
COUNT(E.STUDENT_ID)
-------------------
214 Yvonne,Williams
4
124 Daniel,Wicelinski
4