Oracle SQL - Write SQL to list the code and description of all courses with an exact duration of four days.

Requirements

Here is the table

Demo

SQL>
SQL> drop table courses;

Table dropped.-- from w w w.  ja v a 2  s .c o  m

SQL> create table courses(
  2  code        VARCHAR2(6)  primary key,
  3  description VARCHAR2(30) not null,
  4  category    CHAR(3)      not null,
  5  duration    NUMBER(2)    not null) ;
SQL> insert into courses values('SQL','Introduction to SQL',         'GEN',4);
SQL> insert into courses values('JSON','Oracle for application users','GEN',1);
SQL> insert into courses values('JAVA','Java for Oracle developers',  'BLD',4);
SQL> insert into courses values('PLS','Introduction to PL/SQL',      'BLD',1);
SQL> insert into courses values('XML','XML for Oracle developers',   'BLD',2);
SQL> insert into courses values('ERM','Data modeling with ERM',      'DSG',3);
SQL> insert into courses values('PMT','Process modeling techniques', 'DSG',1);
SQL> insert into courses values('RSD','Relational system design',    'DEF',2);
SQL> insert into courses values('PRO','Prototyping',                 'DSG',5);
SQL> insert into courses values('GEN','System generation',           'DSG',4);
SQL>

Write SQL to Provide the code and description of all courses with an exact duration of four days.

Demo

SQL>
SQL>-- from w  w  w . j a v a  2 s. c o m
SQL> select code, description
  2  from   courses
  3  where  duration = 4;

CODE   DESCRIPTION
------ ------------------------------
SQL    Introduction to SQL
JAVA   Java for Oracle developers
GEN    System generation

SQL>