SlideShare uma empresa Scribd logo
1 de 21
RELATIONAL OBJECT DATABASE COURSE
  University of Maryland University College
               Summer 2011
                    BY
                Sunny Okoro
Development Tools


Database Platform: Oracle 10 and 11G

Applications: Oracle SQL Developer and NotePad Plus.
/*Object Relational Database Activities*/

SQL> CREATE TYPE person_typ AS OBJECT (
  2    idno           NUMBER,
  3    first_nameVARCHAR2(20),
  4    last_nameVARCHAR2(25),
  5    email          VARCHAR2(25),
  6    phone          VARCHAR2(20),
  7    MAP MEMBER FUNCTION get_idno RETURN NUMBER,
  8    MEMBER PROCEDURE display_details( SELF IN OUT NOCOPY person_typ
));
9 /

Type created.

SQL> CREATE TYPE BODY person_typ AS
  2    MAP MEMBER FUNCTION get_idno RETURN NUMBER IS
  3    BEGIN
  4      RETURN idno;
  5    END;
  6    MEMBER PROCEDURE display_details( SELF IN OUT NOCOPY person_typ
) IS
  7    BEGIN
  8      -- use the PUT_LINE procedure of the DBMS_OUTPUT package to
display details
  9      DBMS_OUTPUT.PUT_LINE(TO_CHAR(idno) || ' ' || first_name || '
' || last_name);
 10      DBMS_OUTPUT.PUT_LINE(email || ' ' || phone);
 11    END;
12 END;
13 /

Type body created.

SQL> CREATE TABLE contacts (
  2    contact         person_typ,
  3    contact_dateDATE );

Table created.

SQL>
SQL> INSERT INTO contacts VALUES (
  2    person_typ (65, 'Verna', 'Mills', 'vmills@oracle.com', '1-800-
555-4412'),
  3   '24 Jun 2003' );

1 row created.
SQL> SELECT c.contact.get_idno() FROM contacts c;

C.CONTACT.GET_IDNO()
--------------------
                  65

SQL>desc contacts;
 Name                                      Null?      Type
 ----------------------------------------- --------   ------------------
----------
 CONTACT                                              PERSON_TYP
 CONTACT_DATE                                         DATE

SQL> select * from contacts;

CONTACT(IDNO, FIRST_NAME, LAST_NAME, EMAIL, PHONE)
----------------------------------------------------------------------
----------
CONTACT_D
---------
PERSON_TYP(65, 'Verna', 'Mills', 'vmills@oracle.com', '1-800-555-
4412')
24-JUN-03


SQL> create type student_3 as object (
2 student_id number,
3 first_name varchar2(50),
4 last_name varchar2(50)
5 );
6 /

Type created.

SQL> create table graduate_1
2 (
  3   stud student_3,
  4   Degree_Title Varchar2(30),
  5   Major_1 varchar2(24)
6 );

Table created.

SQL> create sequence student_id
2 start with 090866
3 increment by 4500
4 nocycle;

Sequence created.

SQL>
SQL> insert into graduate_1 values (student_3 (0900, 'sunny',
'jackson'),'Masters of Arts', 'Oil Painting');

1 row created.

SQL>
SQL> insert into graduate_1 values (student_3 (078999, 'Rob',
'Howard'),'Masters Education', 'Pyschology' );

1 row created.

SQL>
SQL> insert into graduate_1 values (student_3 (student_id.nextval,
'Kevin', 'jackson'),'Masters of Technology', 'Database Systems');

1 row created.

SQL> commit;

Commit complete.

SQL> create table undergrad_1
2 (
  3   stud student_3,
  4   Degree_Title Varchar2(30),
  5   Major_1 varchar2(30),
  6   Minor varchar2(40)
7 );

Table created.



SQL>
SQL> insert into undergrad_1 values (student_3 (student_id.nextval,
'Michael', 'Young'), 'Beacholar of Technology', 'Web Technologies',
'None');

1 row created.

SQL> insert into undergrad_1 values (student_3 (student_id.nextval,
'Mary', 'MackNell'), 'Beacholar of Science', 'Biology', 'None');

1 row created.

SQL> commit;

Commit complete.

SQL>desc graduate_1
 Name                                     Null?    Type
----------------------------------------- -------- ------------------
----------
 STUD                                               STUDENT_3
 DEGREE_TITLE                                       VARCHAR2(30)
 MAJOR_1                                            VARCHAR2(24)

SQL> select * from graduate_1;

STUD(STUDENT_ID, FIRST_NAME, LAST_NAME)
----------------------------------------------------------------------
----------
DEGREE_TITLE                   MAJOR_1
------------------------------ ------------------------
STUDENT_3(900, 'sunny', 'jackson')
Masters of Arts                Oil Painting

STUDENT_3(78999, 'Rob', 'Howard')
Masters Education              Pyschology

STUDENT_3(90866, 'Kevin', 'jackson')
Masters of Technology          Database Systems


SQL>desc undergrad_1
 Name                                      Null?      Type
 ----------------------------------------- --------   ------------------
----------
 STUD                                                 STUDENT_3
 DEGREE_TITLE                                         VARCHAR2(30)
 MAJOR_1                                              VARCHAR2(30)
 MINOR                                                VARCHAR2(40)

SQL> select * from undergrad_1;

STUD(STUDENT_ID, FIRST_NAME, LAST_NAME)
----------------------------------------------------------------------
----------
DEGREE_TITLE                   MAJOR_1
------------------------------ ------------------------------
MINOR
----------------------------------------
STUDENT_3(95366, 'Michael', 'Young')
Beacholar of Technology        Web Technologies
None

STUDENT_3(99866, 'Mary', 'MackNell')
Beacholar of Science           Biology
None

STUD(STUDENT_ID, FIRST_NAME, LAST_NAME)
----------------------------------------------------------------------
----------
DEGREE_TITLE                   MAJOR_1
------------------------------ ------------------------------
MINOR
----------------------------------------


SQL>


SQL> insert into undergrad_1 values (student_3 (078999, 'Rob',
'Howard'), 'Beacholar of Education', 'Early Child Educ',
'Psychology');

1 row created.

SQL> select * from undergrad_1;

STUD(STUDENT_ID, FIRST_NAME, LAST_NAME)
----------------------------------------------------------------------
----------
DEGREE_TITLE                   MAJOR_1
------------------------------ ------------------------------
MINOR
----------------------------------------
STUDENT_3(95366, 'Michael', 'Young')
Beacholar of Technology        Web Technologies
None

STUDENT_3(99866, 'Mary', 'MackNell')
Beacholar of Science           Biology
None

STUD(STUDENT_ID, FIRST_NAME, LAST_NAME)
----------------------------------------------------------------------
----------
DEGREE_TITLE                   MAJOR_1
------------------------------ ------------------------------
MINOR
----------------------------------------

STUDENT_3(78999, 'Rob', 'Howard')
Beacholar of Education         Early Child Educ
Psychology



/* REGULAR QUERY*/

select *
from (select cost, count(*) num_of_rows from course
group by cost) course_cost
pivot (sum(num_of_rows)
for cost in (1095, 1195, 1595, null));

      1095       1195       1595       NULL
---------- ---------- ---------- ----------
         3         25          1          1



Select count ( case when cost = 1095 then 1 end ) "1095",
count(case when cost = 1195 then 1 end ) "1195",
count(case when cost = 1595 then 1 end ) "1595",
count(case when cost is null then 1 end ) "null" from course;

      1095       1195       1595       null
---------- ---------- ---------- ----------
         3         25          1          1

select count(decode(cost, 1095, 1)) "1095",
count(decode(cost, 1195, 1)) "1195",
count (decode(cost, 1595, 1)) "1595",
count(decode(cost, null, 1))"null" from course;

      1095       1195       1595       null
---------- ---------- ---------- ----------
         3         25          1          1

selectcourse_no, revenue, rev_dense_rank
from (select course_no, revenue, dense_rank() over (order by revenue
desc)
rev_dense_rank from course_revenue ) t
where rev_dense_rank<=3;

 COURSE_NO    REVENUE REV_DENSE_RANK
---------- ---------- --------------
        25      53775              1
       122      28680              2
       120      27485              3

selectcourse_no, revenue, rev_dense_rank
from (select course_no, revenue, dense_rank() over (order by revenue
asc)
rev_dense_rank from course_revenue ) t
where rev_dense_rank<=3;

 COURSE_NO    REVENUE REV_DENSE_RANK
---------- ---------- --------------
        10       1195              1
       204       1195              1
       132       2390              2
       145       2390              2
       420       2390              2
       134       2390              2
146          3585            3
      330          3585            3

8 rows selected.



selectcourse_no, revenue,
row_number() over (partition by course_no order by revenue
desc)"rownum"
fromcourse_revenue
order by course_no, revenue;

 COURSE_NO    REVENUE     rownum
---------- ---------- ----------
        10       1195          1
        20      10755          1
        25      53775          1
       100      15535          1
       120      27485          1
       122      28680          1
       124       9560          1
       125       9560          1
       130       9560          1
       132       2390          1
       134       2390          1

 COURSE_NO    REVENUE     rownum
---------- ---------- ----------
       135       4380          1
       140      17925          1
       142       8365          1
       145       2390          1
       146       3585          1
       147       5975          1
       204       1195          1
       230      15330          1
       240      14235          1
       310       4780          1
       330       3585          1

 COURSE_NO    REVENUE     rownum
---------- ---------- ----------
       350      10755          1
       420       2390          1

24 rows selected.


selectnumeric_grade as grade, grade_type_code,
grade_code_occurrence as occurrence,
ROUND (AVG (numeric_grade) over (partition by grade_type_code)) AS
avg
from grade
wherestudent_id = 254
andsection_id = 87;

     GRADE   GR OCCURRENCE        AVG
----------   -- ---------- ----------
        91   FI          1         91
        91   HM          1         85
        75   HM          2         85
        98   HM          3         85
        98   HM          4         85
        81   HM          5         85
        71   HM          6         85
        71   HM          7         85
        81   HM          8         85
        91   HM          9         85
        91   HM         10         85

     GRADE GR OCCURRENCE        AVG
---------- -- ---------- ----------
        76 MT          1         76

12 rows selected.




selectstudent_id, first_name ||','||last_name as "Student_ Name" from
student;

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       102   Fred,Crocitto
       103   J.,Landry
       104   Laetia,Enison
       105   Angel,Moskowitz
       106   Judith,Olvsade
       107   Catherine,Mierzwa
       108   Judy,Sethi
       109   Larry,Walter
       110   Maria,Martin
       111   Peggy,Noviello
       112   Thomas,Thomas

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       113   Anil,Kulina
       114   Winsome,Laporte
       117   N,Kuehn
       118   Hiedi,Lopez
119    Mardig,Abdou
      120    Ralph,Alexander
      121    Sean,Pineda
      122    Julita,Lippen
      123    Pierre,Radicola
      124    Daniel,Wicelinski
      127    Gary,Aung

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       128   Jeff,Runyan
       129   Omaira,Grant
       130   Lula,Oates
       133   James,Reed
       134   Angela,Torres
       135   Michelle,Masser
       136   Hazel,Lasseter
       137   James,Miller
       138   John,Smith
       139   Angelo,Garshman
       140   Derrick,Baltazar

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       141   Robert,Boyd
       142   Monica,Waldman
       143   Gerard,Biers
       144   David,Essner
       145   Paul,Lefkowitz
       146   Joseph,German
       147   Judy,Cahouet
       148   D.,Orent
       149   Judith,Prochaska
       150   Regina,Gates
       151   Arlyne,Sheppard

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       152   Thomas,Edwards
       153   Mrudula,Philpotts
       154   Dawn,Dennis
       156   Scott,Grant
       157   Shirley,Jameson
       158   Roy,Limate
       159   Thomas,Edwards
       160   John T.,Beitler
       161   Eilene,Grant
       162   Genny,Andrew
       163   Nicole,Gillen

STUDENT_ID Student_ Name
---------- ---------------------------------------------------
164    Sylvia,Perrin
      165    Peter,Daly
      166    May,Jodoin
      167    Jim,Joas
      168    Sally,Naso
      169    Frantz,McLean
      170    P.,Balterzar
      171    Denise,Brownstein
      172    Maria,Arias
      173    Oscar,McGill
      174    Michael,Brown

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       175   Debra,Boyce
       176   Beth,Satterfield
       178   Ricardo,Kurtz
       179   Simon,Ramesh
       180   E.A.,Torres
       181   Anthony,Bullock
       182   Jeffrey,Delbrun
       184   Salewa,Zuckerberg
       185   Dennis,Mehta
       186   Christine,Sheppard
       187   O.,Garnes

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       188   Phil,Gilloon
       189   Deborah,Reyes
       190   Alan,Affinito
       191   Steven,M. Orent
       192   Frank,Viotty
       193   Al,Jamerncy
       194   Verona,Grant
       195   Regina,Bose
       196   Victor,Meshaj
       197   J.,Dalvi
       198   Edwin,Allende

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       199   J.,Segall
       200   Gene,Bresser, HR Rep.
       201   Michael,Lefbowitz
       202   Mary,Axch
       203   Angel,Cook
       204   Arun,Griffen
       205   Alfred,Hutheesing
       206   Freedon,annunziato
       207   Bernadette,Montanez
       208   A.,Tucker
209 Lloyd,Kellam

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       210   David,Thares
       211   Jenny,Goldsmith
       212   Barbara,Robichaud
       214   Yvonne,Williams
       215   Reynaldo,Chatman
       216   Madhav,Dusenberry
       217   Jeffrey,Citron
       218   Eric,Da Silva
       220   Robert,Segall
       221   Sheradha,Malone
       223   Frank,Pace

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       224   M.,Diokno
       225   Edgar,Moffat
       227   Bessie,Heedles
       228   Mohamed,Valentine
       229   Adrienne,Lopez
       230   George,Kocka
       232   Janet,Jung
       233   Kathleen,Mulroy
       234   Joel,Brendler
       235   Michael,Carcia
       236   Gerry,Tripp

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       237   Rommel,Frost
       238   Roger,Snow
       240   Z.A.,Scrittorale
       241   Joseph,Yourish
       242   Daniel,Ordes
       243   Bharat,Roberts
       244   Sarah,Wilson
       245   Irv,Dalvi
       246   Meryl,Owens
       247   Frank,Bunnell
       248   Tamara,Zapulla

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       250   Evan,Fielding
       251   Catherine,Frangopoulos
       252   Nana,Barogh
       253   Walter,Boremmann
       254   Melvina,Chamnonkool
       256   Lorrane,Velasco
257    Suzanne M.,Abid
      258    Suzanna,Velasco
      259    George,Merriman
      260    Jean,Griffith
      261    Vinnie,Moon

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       262   Donna,Walston
       263   Radharam,King
       264   Lorraine,Harty
       265   Adele,Rothstein
       266   Kate,Page
       267   Julius,Kwong
       268   Ronald,Tangaribuan
       269   Sharon,Thompson
       270   Charles,Caro
       271   Jose,Benitez
       272   Kevin,Porch

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       273   Hedy,Naso
       274   John,De Simone
       275   George,Ross
       276   Florence,Valamas
       277   Evelyn,Liggons
       278   Thomas E.,La Blank
       279   George,Korka
       280   Bill,Engongoro
       281   Virginia,Ocampo
       282   Jonathan,Jaele
       283   Benita,Perkins

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       284   Salewa,Lindeman
       285   Paul,Sikinger
       286   Robin,Kelly
       288   Rosemary,Ellman
       289   Shirley,Murray
       290   Brian,Robles
       291   D.,Dewitt
       292   Austin V.,Cadet
       293   Frank,M. Orent
       294   Yvonne,Winnicki
       296   Mike,Madej

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       298   Paula,Valentine
       299   Brian,Saluja
300    Frances,Lawson
      301    Barry,Dunkon
      302    Rita,Archor
      303    George,Milano
      304    Kardik,Guarino
      305    Preston,Larcia
      306    Norman,Callender
      307    Salondra,Galik
      309    Carlos,Airall

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       310   Joseph,Jimenes
       311   Henry,Masser
       312   Maria,Allende
       313   John,Velie
       314   Bernice,Dermody
       315   Daniel,McHowell
       317   Cathy,Austin
       319   George,Eakheit
       320   Mark,Miller
       321   Jeannette,Smagler
       322   Oscar,Archer

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       323   Gilbert,Ginestra
       324   Price,Marten
       325   Pat,Puetrino
       326   Piotr,Padel
       328   Lynwood A.,Thorton
       330   John,Tabs
       331   Mei-Wah,Zopf
       332   Paula,Mwangi
       333   Artie,Ward
       334   Sarah,Annina
       335   Jane,Jackson

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       336   Steven,Gallagher
       337   Preston,Cross
       338   Helga,Towle
       339   Piang,Nyziak
       340   David,Eng
       341   Kevin,Porch
       342   Marianne,DeArmas
       343   Ray,Schafer
       344   R.,Sprouse
       345   Peter,Carey
       346   Joane,Buckberg
STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       347   Edith,Daly
       348   Morty,Miller
       349   Margaret,Mandel
       351   Alan,Galik
       352   Debra,Shah
       353   Paul,Intal
       355   Romeo,Ittoop
       356   John,Ancean
       357   Tom,Vargas
       358   Valerie,Avia
       359   Fermin,Galik

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       360   Calvin,Kiraly
       361   Rawan,Rosenberg
       362   Yu,Sentell
       363   Bridget,Hagel
       364   Howard,Leopta
       365   Kathleen,Mastandora
       366   Gabriel,Smith
       367   Raymond,Cheevens
       368   Kevin,Lin
       369   Lorraine,Tucker
       370   John,Mithane

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       371   Craig,Anglin
       372   Zalman,Draquez
       373   Reeva,Yeroushalmi
       374   Leonard,Millstein
       375   Jack,Kasperovich
       376   Lorelei,McNeal
       378   William,Gallo
       379   Craig,Padron
       380   Joel,Krot
       381   Allan,Simmons
       382   Michael,Miroff

STUDENT_ID   Student_ Name
----------   ---------------------------------------------------
       383   Roger,Cowie
       384   Asian,Chirichella
       385   Yvonne,Allende
       386   Sengita,MacDonald, Jr.
       387   Paul,Braun
       388   Anna,Bathmanapan
       389   Shirley,Leung
       390   V.,Greenberg
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')
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
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')),
()
   );

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
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

Mais conteúdo relacionado

Destaque

3 mathijsen-verkooijen
3 mathijsen-verkooijen3 mathijsen-verkooijen
3 mathijsen-verkooijenLejla Alic
 
Lyserødlørdag 2012
Lyserødlørdag 2012Lyserødlørdag 2012
Lyserødlørdag 2012Merethe Kepp
 
Grow mybusiness
Grow mybusinessGrow mybusiness
Grow mybusinesskylene22
 
My lucky number
My lucky numberMy lucky number
My lucky numberhuehue122
 
Genetika
Genetika Genetika
Genetika mundu1d
 
Representation key concepts
Representation key conceptsRepresentation key concepts
Representation key conceptsnctcmedia12
 
V.Bisters prezentacija
V.Bisters prezentacijaV.Bisters prezentacija
V.Bisters prezentacijaconsumerenergy
 
Some useful tips with qtp
Some useful tips with qtpSome useful tips with qtp
Some useful tips with qtpSandeep
 
The essentia bhiwadi brochure
The essentia bhiwadi brochureThe essentia bhiwadi brochure
The essentia bhiwadi brochureSunil Sood
 
Cilc2013 .hr.wk.ewv 20130314
Cilc2013 .hr.wk.ewv 20130314Cilc2013 .hr.wk.ewv 20130314
Cilc2013 .hr.wk.ewv 20130314Heimo Rainer
 
West cork local 26 jan
West cork local 26 janWest cork local 26 jan
West cork local 26 janWCLN
 
Свеча зажигания Bosch
Свеча зажигания BoschСвеча зажигания Bosch
Свеча зажигания BoschAl Maks
 
Two way fine art pen & brush
Two way fine art pen & brushTwo way fine art pen & brush
Two way fine art pen & brushibec546
 
Sybase SQL AnyWhere12
Sybase SQL AnyWhere12Sybase SQL AnyWhere12
Sybase SQL AnyWhere12Sunny U Okoro
 

Destaque (20)

3 mathijsen-verkooijen
3 mathijsen-verkooijen3 mathijsen-verkooijen
3 mathijsen-verkooijen
 
Oracle 11G- PLSQL
Oracle 11G- PLSQLOracle 11G- PLSQL
Oracle 11G- PLSQL
 
Lyserødlørdag 2012
Lyserødlørdag 2012Lyserødlørdag 2012
Lyserødlørdag 2012
 
Grow mybusiness
Grow mybusinessGrow mybusiness
Grow mybusiness
 
SKA
SKA SKA
SKA
 
My lucky number
My lucky numberMy lucky number
My lucky number
 
Mekanismoak01
Mekanismoak01Mekanismoak01
Mekanismoak01
 
Genetika
Genetika Genetika
Genetika
 
Representation key concepts
Representation key conceptsRepresentation key concepts
Representation key concepts
 
V.Bisters prezentacija
V.Bisters prezentacijaV.Bisters prezentacija
V.Bisters prezentacija
 
Some useful tips with qtp
Some useful tips with qtpSome useful tips with qtp
Some useful tips with qtp
 
Alliant Group
Alliant Group Alliant Group
Alliant Group
 
The essentia bhiwadi brochure
The essentia bhiwadi brochureThe essentia bhiwadi brochure
The essentia bhiwadi brochure
 
The dark Flood
The dark FloodThe dark Flood
The dark Flood
 
Cilc2013 .hr.wk.ewv 20130314
Cilc2013 .hr.wk.ewv 20130314Cilc2013 .hr.wk.ewv 20130314
Cilc2013 .hr.wk.ewv 20130314
 
West cork local 26 jan
West cork local 26 janWest cork local 26 jan
West cork local 26 jan
 
Свеча зажигания Bosch
Свеча зажигания BoschСвеча зажигания Bosch
Свеча зажигания Bosch
 
administracion de empresas
administracion de empresasadministracion de empresas
administracion de empresas
 
Two way fine art pen & brush
Two way fine art pen & brushTwo way fine art pen & brush
Two way fine art pen & brush
 
Sybase SQL AnyWhere12
Sybase SQL AnyWhere12Sybase SQL AnyWhere12
Sybase SQL AnyWhere12
 

Semelhante a Relational DB Course

SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所Hiroshi Sekiguchi
 
12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction12c Mini Lesson - Data Redaction
12c Mini Lesson - Data RedactionConnor McDonald
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceKaren Morton
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developersInSync Conference
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersConnor McDonald
 
More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cGuatemala User Group
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application DevelopmentSaurabh K. Gupta
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfPraveenPolu1
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleGuatemala User Group
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013Connor McDonald
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald PartitioningInSync Conference
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersRiyaj Shamsudeen
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersEnkitec
 

Semelhante a Relational DB Course (20)

Sql queries
Sql queriesSql queries
Sql queries
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
 
12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction12c Mini Lesson - Data Redaction
12c Mini Lesson - Data Redaction
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Sql 3
Sql 3Sql 3
Sql 3
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developers
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer Disasters
 
More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12c
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application Development
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
EvolveExecutionPlans.pdf
EvolveExecutionPlans.pdfEvolveExecutionPlans.pdf
EvolveExecutionPlans.pdf
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
 
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleUnderstanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald Partitioning
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-Developers
 
Sql2
Sql2Sql2
Sql2
 

Mais de Sunny U Okoro

SQL Server and SSAS
SQL Server and SSAS SQL Server and SSAS
SQL Server and SSAS Sunny U Okoro
 
BI Apps Reports 5 QlikSense Desktop
BI Apps Reports 5  QlikSense DesktopBI Apps Reports 5  QlikSense Desktop
BI Apps Reports 5 QlikSense DesktopSunny U Okoro
 
MS SSAS 2008 & MDX Reports
MS SSAS 2008 &  MDX Reports MS SSAS 2008 &  MDX Reports
MS SSAS 2008 & MDX Reports Sunny U Okoro
 
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseDBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseSunny U Okoro
 
BI Apps ETL 4- Informatica PowerCenter Express
BI  Apps ETL 4- Informatica PowerCenter  ExpressBI  Apps ETL 4- Informatica PowerCenter  Express
BI Apps ETL 4- Informatica PowerCenter ExpressSunny U Okoro
 
BI Apps Reports 4 Cognos BI and Crystal Reports
BI Apps Reports 4  Cognos BI and Crystal ReportsBI Apps Reports 4  Cognos BI and Crystal Reports
BI Apps Reports 4 Cognos BI and Crystal ReportsSunny U Okoro
 
Tableau Reports and Oracle OBIEE
Tableau Reports and  Oracle OBIEETableau Reports and  Oracle OBIEE
Tableau Reports and Oracle OBIEESunny U Okoro
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server Sunny U Okoro
 
Advanced ETL2 Pentaho
Advanced ETL2  Pentaho Advanced ETL2  Pentaho
Advanced ETL2 Pentaho Sunny U Okoro
 
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsBI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsSunny U Okoro
 
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012Sunny U Okoro
 
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional Sunny U Okoro
 
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsAdvanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsSunny U Okoro
 
Advanced ETL MS SSIS 2012 & Talend
Advanced ETL  MS  SSIS 2012 & Talend Advanced ETL  MS  SSIS 2012 & Talend
Advanced ETL MS SSIS 2012 & Talend Sunny U Okoro
 
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16  DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16 Sunny U Okoro
 
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsDB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsSunny U Okoro
 

Mais de Sunny U Okoro (20)

SQL Server and SSAS
SQL Server and SSAS SQL Server and SSAS
SQL Server and SSAS
 
BI Apps Reports 5 QlikSense Desktop
BI Apps Reports 5  QlikSense DesktopBI Apps Reports 5  QlikSense Desktop
BI Apps Reports 5 QlikSense Desktop
 
MS SSAS 2008 & MDX Reports
MS SSAS 2008 &  MDX Reports MS SSAS 2008 &  MDX Reports
MS SSAS 2008 & MDX Reports
 
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseDBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
 
Database Migration
Database MigrationDatabase Migration
Database Migration
 
Cognos Express
Cognos ExpressCognos Express
Cognos Express
 
BI Apps ETL 4- Informatica PowerCenter Express
BI  Apps ETL 4- Informatica PowerCenter  ExpressBI  Apps ETL 4- Informatica PowerCenter  Express
BI Apps ETL 4- Informatica PowerCenter Express
 
Oracle ODI
Oracle ODIOracle ODI
Oracle ODI
 
BI Apps Reports 4 Cognos BI and Crystal Reports
BI Apps Reports 4  Cognos BI and Crystal ReportsBI Apps Reports 4  Cognos BI and Crystal Reports
BI Apps Reports 4 Cognos BI and Crystal Reports
 
Tableau Reports and Oracle OBIEE
Tableau Reports and  Oracle OBIEETableau Reports and  Oracle OBIEE
Tableau Reports and Oracle OBIEE
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server
 
MS SSAS 2012 & MDX
MS SSAS 2012  &  MDXMS SSAS 2012  &  MDX
MS SSAS 2012 & MDX
 
Advanced ETL2 Pentaho
Advanced ETL2  Pentaho Advanced ETL2  Pentaho
Advanced ETL2 Pentaho
 
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsBI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
 
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
 
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
 
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsAdvanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
 
Advanced ETL MS SSIS 2012 & Talend
Advanced ETL  MS  SSIS 2012 & Talend Advanced ETL  MS  SSIS 2012 & Talend
Advanced ETL MS SSIS 2012 & Talend
 
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16  DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsDB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Relational DB Course

  • 1. RELATIONAL OBJECT DATABASE COURSE University of Maryland University College Summer 2011 BY Sunny Okoro
  • 2. Development Tools Database Platform: Oracle 10 and 11G Applications: Oracle SQL Developer and NotePad Plus.
  • 3. /*Object Relational Database Activities*/ SQL> CREATE TYPE person_typ AS OBJECT ( 2 idno NUMBER, 3 first_nameVARCHAR2(20), 4 last_nameVARCHAR2(25), 5 email VARCHAR2(25), 6 phone VARCHAR2(20), 7 MAP MEMBER FUNCTION get_idno RETURN NUMBER, 8 MEMBER PROCEDURE display_details( SELF IN OUT NOCOPY person_typ )); 9 / Type created. SQL> CREATE TYPE BODY person_typ AS 2 MAP MEMBER FUNCTION get_idno RETURN NUMBER IS 3 BEGIN 4 RETURN idno; 5 END; 6 MEMBER PROCEDURE display_details( SELF IN OUT NOCOPY person_typ ) IS 7 BEGIN 8 -- use the PUT_LINE procedure of the DBMS_OUTPUT package to display details 9 DBMS_OUTPUT.PUT_LINE(TO_CHAR(idno) || ' ' || first_name || ' ' || last_name); 10 DBMS_OUTPUT.PUT_LINE(email || ' ' || phone); 11 END; 12 END; 13 / Type body created. SQL> CREATE TABLE contacts ( 2 contact person_typ, 3 contact_dateDATE ); Table created. SQL> SQL> INSERT INTO contacts VALUES ( 2 person_typ (65, 'Verna', 'Mills', 'vmills@oracle.com', '1-800- 555-4412'), 3 '24 Jun 2003' ); 1 row created.
  • 4. SQL> SELECT c.contact.get_idno() FROM contacts c; C.CONTACT.GET_IDNO() -------------------- 65 SQL>desc contacts; Name Null? Type ----------------------------------------- -------- ------------------ ---------- CONTACT PERSON_TYP CONTACT_DATE DATE SQL> select * from contacts; CONTACT(IDNO, FIRST_NAME, LAST_NAME, EMAIL, PHONE) ---------------------------------------------------------------------- ---------- CONTACT_D --------- PERSON_TYP(65, 'Verna', 'Mills', 'vmills@oracle.com', '1-800-555- 4412') 24-JUN-03 SQL> create type student_3 as object ( 2 student_id number, 3 first_name varchar2(50), 4 last_name varchar2(50) 5 ); 6 / Type created. SQL> create table graduate_1 2 ( 3 stud student_3, 4 Degree_Title Varchar2(30), 5 Major_1 varchar2(24) 6 ); Table created. SQL> create sequence student_id 2 start with 090866 3 increment by 4500 4 nocycle; Sequence created. SQL>
  • 5. SQL> insert into graduate_1 values (student_3 (0900, 'sunny', 'jackson'),'Masters of Arts', 'Oil Painting'); 1 row created. SQL> SQL> insert into graduate_1 values (student_3 (078999, 'Rob', 'Howard'),'Masters Education', 'Pyschology' ); 1 row created. SQL> SQL> insert into graduate_1 values (student_3 (student_id.nextval, 'Kevin', 'jackson'),'Masters of Technology', 'Database Systems'); 1 row created. SQL> commit; Commit complete. SQL> create table undergrad_1 2 ( 3 stud student_3, 4 Degree_Title Varchar2(30), 5 Major_1 varchar2(30), 6 Minor varchar2(40) 7 ); Table created. SQL> SQL> insert into undergrad_1 values (student_3 (student_id.nextval, 'Michael', 'Young'), 'Beacholar of Technology', 'Web Technologies', 'None'); 1 row created. SQL> insert into undergrad_1 values (student_3 (student_id.nextval, 'Mary', 'MackNell'), 'Beacholar of Science', 'Biology', 'None'); 1 row created. SQL> commit; Commit complete. SQL>desc graduate_1 Name Null? Type
  • 6. ----------------------------------------- -------- ------------------ ---------- STUD STUDENT_3 DEGREE_TITLE VARCHAR2(30) MAJOR_1 VARCHAR2(24) SQL> select * from graduate_1; STUD(STUDENT_ID, FIRST_NAME, LAST_NAME) ---------------------------------------------------------------------- ---------- DEGREE_TITLE MAJOR_1 ------------------------------ ------------------------ STUDENT_3(900, 'sunny', 'jackson') Masters of Arts Oil Painting STUDENT_3(78999, 'Rob', 'Howard') Masters Education Pyschology STUDENT_3(90866, 'Kevin', 'jackson') Masters of Technology Database Systems SQL>desc undergrad_1 Name Null? Type ----------------------------------------- -------- ------------------ ---------- STUD STUDENT_3 DEGREE_TITLE VARCHAR2(30) MAJOR_1 VARCHAR2(30) MINOR VARCHAR2(40) SQL> select * from undergrad_1; STUD(STUDENT_ID, FIRST_NAME, LAST_NAME) ---------------------------------------------------------------------- ---------- DEGREE_TITLE MAJOR_1 ------------------------------ ------------------------------ MINOR ---------------------------------------- STUDENT_3(95366, 'Michael', 'Young') Beacholar of Technology Web Technologies None STUDENT_3(99866, 'Mary', 'MackNell') Beacholar of Science Biology None STUD(STUDENT_ID, FIRST_NAME, LAST_NAME) ---------------------------------------------------------------------- ----------
  • 7. DEGREE_TITLE MAJOR_1 ------------------------------ ------------------------------ MINOR ---------------------------------------- SQL> SQL> insert into undergrad_1 values (student_3 (078999, 'Rob', 'Howard'), 'Beacholar of Education', 'Early Child Educ', 'Psychology'); 1 row created. SQL> select * from undergrad_1; STUD(STUDENT_ID, FIRST_NAME, LAST_NAME) ---------------------------------------------------------------------- ---------- DEGREE_TITLE MAJOR_1 ------------------------------ ------------------------------ MINOR ---------------------------------------- STUDENT_3(95366, 'Michael', 'Young') Beacholar of Technology Web Technologies None STUDENT_3(99866, 'Mary', 'MackNell') Beacholar of Science Biology None STUD(STUDENT_ID, FIRST_NAME, LAST_NAME) ---------------------------------------------------------------------- ---------- DEGREE_TITLE MAJOR_1 ------------------------------ ------------------------------ MINOR ---------------------------------------- STUDENT_3(78999, 'Rob', 'Howard') Beacholar of Education Early Child Educ Psychology /* REGULAR QUERY*/ select * from (select cost, count(*) num_of_rows from course group by cost) course_cost pivot (sum(num_of_rows)
  • 8. for cost in (1095, 1195, 1595, null)); 1095 1195 1595 NULL ---------- ---------- ---------- ---------- 3 25 1 1 Select count ( case when cost = 1095 then 1 end ) "1095", count(case when cost = 1195 then 1 end ) "1195", count(case when cost = 1595 then 1 end ) "1595", count(case when cost is null then 1 end ) "null" from course; 1095 1195 1595 null ---------- ---------- ---------- ---------- 3 25 1 1 select count(decode(cost, 1095, 1)) "1095", count(decode(cost, 1195, 1)) "1195", count (decode(cost, 1595, 1)) "1595", count(decode(cost, null, 1))"null" from course; 1095 1195 1595 null ---------- ---------- ---------- ---------- 3 25 1 1 selectcourse_no, revenue, rev_dense_rank from (select course_no, revenue, dense_rank() over (order by revenue desc) rev_dense_rank from course_revenue ) t where rev_dense_rank<=3; COURSE_NO REVENUE REV_DENSE_RANK ---------- ---------- -------------- 25 53775 1 122 28680 2 120 27485 3 selectcourse_no, revenue, rev_dense_rank from (select course_no, revenue, dense_rank() over (order by revenue asc) rev_dense_rank from course_revenue ) t where rev_dense_rank<=3; COURSE_NO REVENUE REV_DENSE_RANK ---------- ---------- -------------- 10 1195 1 204 1195 1 132 2390 2 145 2390 2 420 2390 2 134 2390 2
  • 9. 146 3585 3 330 3585 3 8 rows selected. selectcourse_no, revenue, row_number() over (partition by course_no order by revenue desc)"rownum" fromcourse_revenue order by course_no, revenue; COURSE_NO REVENUE rownum ---------- ---------- ---------- 10 1195 1 20 10755 1 25 53775 1 100 15535 1 120 27485 1 122 28680 1 124 9560 1 125 9560 1 130 9560 1 132 2390 1 134 2390 1 COURSE_NO REVENUE rownum ---------- ---------- ---------- 135 4380 1 140 17925 1 142 8365 1 145 2390 1 146 3585 1 147 5975 1 204 1195 1 230 15330 1 240 14235 1 310 4780 1 330 3585 1 COURSE_NO REVENUE rownum ---------- ---------- ---------- 350 10755 1 420 2390 1 24 rows selected. selectnumeric_grade as grade, grade_type_code, grade_code_occurrence as occurrence,
  • 10. ROUND (AVG (numeric_grade) over (partition by grade_type_code)) AS avg from grade wherestudent_id = 254 andsection_id = 87; GRADE GR OCCURRENCE AVG ---------- -- ---------- ---------- 91 FI 1 91 91 HM 1 85 75 HM 2 85 98 HM 3 85 98 HM 4 85 81 HM 5 85 71 HM 6 85 71 HM 7 85 81 HM 8 85 91 HM 9 85 91 HM 10 85 GRADE GR OCCURRENCE AVG ---------- -- ---------- ---------- 76 MT 1 76 12 rows selected. selectstudent_id, first_name ||','||last_name as "Student_ Name" from student; STUDENT_ID Student_ Name ---------- --------------------------------------------------- 102 Fred,Crocitto 103 J.,Landry 104 Laetia,Enison 105 Angel,Moskowitz 106 Judith,Olvsade 107 Catherine,Mierzwa 108 Judy,Sethi 109 Larry,Walter 110 Maria,Martin 111 Peggy,Noviello 112 Thomas,Thomas STUDENT_ID Student_ Name ---------- --------------------------------------------------- 113 Anil,Kulina 114 Winsome,Laporte 117 N,Kuehn 118 Hiedi,Lopez
  • 11. 119 Mardig,Abdou 120 Ralph,Alexander 121 Sean,Pineda 122 Julita,Lippen 123 Pierre,Radicola 124 Daniel,Wicelinski 127 Gary,Aung STUDENT_ID Student_ Name ---------- --------------------------------------------------- 128 Jeff,Runyan 129 Omaira,Grant 130 Lula,Oates 133 James,Reed 134 Angela,Torres 135 Michelle,Masser 136 Hazel,Lasseter 137 James,Miller 138 John,Smith 139 Angelo,Garshman 140 Derrick,Baltazar STUDENT_ID Student_ Name ---------- --------------------------------------------------- 141 Robert,Boyd 142 Monica,Waldman 143 Gerard,Biers 144 David,Essner 145 Paul,Lefkowitz 146 Joseph,German 147 Judy,Cahouet 148 D.,Orent 149 Judith,Prochaska 150 Regina,Gates 151 Arlyne,Sheppard STUDENT_ID Student_ Name ---------- --------------------------------------------------- 152 Thomas,Edwards 153 Mrudula,Philpotts 154 Dawn,Dennis 156 Scott,Grant 157 Shirley,Jameson 158 Roy,Limate 159 Thomas,Edwards 160 John T.,Beitler 161 Eilene,Grant 162 Genny,Andrew 163 Nicole,Gillen STUDENT_ID Student_ Name ---------- ---------------------------------------------------
  • 12. 164 Sylvia,Perrin 165 Peter,Daly 166 May,Jodoin 167 Jim,Joas 168 Sally,Naso 169 Frantz,McLean 170 P.,Balterzar 171 Denise,Brownstein 172 Maria,Arias 173 Oscar,McGill 174 Michael,Brown STUDENT_ID Student_ Name ---------- --------------------------------------------------- 175 Debra,Boyce 176 Beth,Satterfield 178 Ricardo,Kurtz 179 Simon,Ramesh 180 E.A.,Torres 181 Anthony,Bullock 182 Jeffrey,Delbrun 184 Salewa,Zuckerberg 185 Dennis,Mehta 186 Christine,Sheppard 187 O.,Garnes STUDENT_ID Student_ Name ---------- --------------------------------------------------- 188 Phil,Gilloon 189 Deborah,Reyes 190 Alan,Affinito 191 Steven,M. Orent 192 Frank,Viotty 193 Al,Jamerncy 194 Verona,Grant 195 Regina,Bose 196 Victor,Meshaj 197 J.,Dalvi 198 Edwin,Allende STUDENT_ID Student_ Name ---------- --------------------------------------------------- 199 J.,Segall 200 Gene,Bresser, HR Rep. 201 Michael,Lefbowitz 202 Mary,Axch 203 Angel,Cook 204 Arun,Griffen 205 Alfred,Hutheesing 206 Freedon,annunziato 207 Bernadette,Montanez 208 A.,Tucker
  • 13. 209 Lloyd,Kellam STUDENT_ID Student_ Name ---------- --------------------------------------------------- 210 David,Thares 211 Jenny,Goldsmith 212 Barbara,Robichaud 214 Yvonne,Williams 215 Reynaldo,Chatman 216 Madhav,Dusenberry 217 Jeffrey,Citron 218 Eric,Da Silva 220 Robert,Segall 221 Sheradha,Malone 223 Frank,Pace STUDENT_ID Student_ Name ---------- --------------------------------------------------- 224 M.,Diokno 225 Edgar,Moffat 227 Bessie,Heedles 228 Mohamed,Valentine 229 Adrienne,Lopez 230 George,Kocka 232 Janet,Jung 233 Kathleen,Mulroy 234 Joel,Brendler 235 Michael,Carcia 236 Gerry,Tripp STUDENT_ID Student_ Name ---------- --------------------------------------------------- 237 Rommel,Frost 238 Roger,Snow 240 Z.A.,Scrittorale 241 Joseph,Yourish 242 Daniel,Ordes 243 Bharat,Roberts 244 Sarah,Wilson 245 Irv,Dalvi 246 Meryl,Owens 247 Frank,Bunnell 248 Tamara,Zapulla STUDENT_ID Student_ Name ---------- --------------------------------------------------- 250 Evan,Fielding 251 Catherine,Frangopoulos 252 Nana,Barogh 253 Walter,Boremmann 254 Melvina,Chamnonkool 256 Lorrane,Velasco
  • 14. 257 Suzanne M.,Abid 258 Suzanna,Velasco 259 George,Merriman 260 Jean,Griffith 261 Vinnie,Moon STUDENT_ID Student_ Name ---------- --------------------------------------------------- 262 Donna,Walston 263 Radharam,King 264 Lorraine,Harty 265 Adele,Rothstein 266 Kate,Page 267 Julius,Kwong 268 Ronald,Tangaribuan 269 Sharon,Thompson 270 Charles,Caro 271 Jose,Benitez 272 Kevin,Porch STUDENT_ID Student_ Name ---------- --------------------------------------------------- 273 Hedy,Naso 274 John,De Simone 275 George,Ross 276 Florence,Valamas 277 Evelyn,Liggons 278 Thomas E.,La Blank 279 George,Korka 280 Bill,Engongoro 281 Virginia,Ocampo 282 Jonathan,Jaele 283 Benita,Perkins STUDENT_ID Student_ Name ---------- --------------------------------------------------- 284 Salewa,Lindeman 285 Paul,Sikinger 286 Robin,Kelly 288 Rosemary,Ellman 289 Shirley,Murray 290 Brian,Robles 291 D.,Dewitt 292 Austin V.,Cadet 293 Frank,M. Orent 294 Yvonne,Winnicki 296 Mike,Madej STUDENT_ID Student_ Name ---------- --------------------------------------------------- 298 Paula,Valentine 299 Brian,Saluja
  • 15. 300 Frances,Lawson 301 Barry,Dunkon 302 Rita,Archor 303 George,Milano 304 Kardik,Guarino 305 Preston,Larcia 306 Norman,Callender 307 Salondra,Galik 309 Carlos,Airall STUDENT_ID Student_ Name ---------- --------------------------------------------------- 310 Joseph,Jimenes 311 Henry,Masser 312 Maria,Allende 313 John,Velie 314 Bernice,Dermody 315 Daniel,McHowell 317 Cathy,Austin 319 George,Eakheit 320 Mark,Miller 321 Jeannette,Smagler 322 Oscar,Archer STUDENT_ID Student_ Name ---------- --------------------------------------------------- 323 Gilbert,Ginestra 324 Price,Marten 325 Pat,Puetrino 326 Piotr,Padel 328 Lynwood A.,Thorton 330 John,Tabs 331 Mei-Wah,Zopf 332 Paula,Mwangi 333 Artie,Ward 334 Sarah,Annina 335 Jane,Jackson STUDENT_ID Student_ Name ---------- --------------------------------------------------- 336 Steven,Gallagher 337 Preston,Cross 338 Helga,Towle 339 Piang,Nyziak 340 David,Eng 341 Kevin,Porch 342 Marianne,DeArmas 343 Ray,Schafer 344 R.,Sprouse 345 Peter,Carey 346 Joane,Buckberg
  • 16. STUDENT_ID Student_ Name ---------- --------------------------------------------------- 347 Edith,Daly 348 Morty,Miller 349 Margaret,Mandel 351 Alan,Galik 352 Debra,Shah 353 Paul,Intal 355 Romeo,Ittoop 356 John,Ancean 357 Tom,Vargas 358 Valerie,Avia 359 Fermin,Galik STUDENT_ID Student_ Name ---------- --------------------------------------------------- 360 Calvin,Kiraly 361 Rawan,Rosenberg 362 Yu,Sentell 363 Bridget,Hagel 364 Howard,Leopta 365 Kathleen,Mastandora 366 Gabriel,Smith 367 Raymond,Cheevens 368 Kevin,Lin 369 Lorraine,Tucker 370 John,Mithane STUDENT_ID Student_ Name ---------- --------------------------------------------------- 371 Craig,Anglin 372 Zalman,Draquez 373 Reeva,Yeroushalmi 374 Leonard,Millstein 375 Jack,Kasperovich 376 Lorelei,McNeal 378 William,Gallo 379 Craig,Padron 380 Joel,Krot 381 Allan,Simmons 382 Michael,Miroff STUDENT_ID Student_ Name ---------- --------------------------------------------------- 383 Roger,Cowie 384 Asian,Chirichella 385 Yvonne,Allende 386 Sengita,MacDonald, Jr. 387 Paul,Braun 388 Anna,Bathmanapan 389 Shirley,Leung 390 V.,Greenberg
  • 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