You are on page 1of 7

create table employee(

EMP_ID NUMBER (6) NOT NULL,

FIRST_NAME VARCHAR2 (20),

LAST_NAME VARCHAR2 (25) NOT NULL,

EMAIL VARCHAR2 (25) NOT NULL,

PHONENUMBER VARCHAR2 (15) NOT NULL,

HIREDATE DATE NOT NULL,

JOB_ID VARCHAR2 (25),

SALARY NUMBER (8) NOT NULL,

COMMISION NUMBER (4, 2),

MANAGER_ID NUMBER (6),

DEPARTMENT_ID NUMBER (4));

insert into employee values(90,'aky','red','ask.reddy@gmail.com','9659885896','5-apr-


2018','65',656000,56,8,12);

Select last_name, salary, salary*12+100 from employee;

Select * from employee where salary between 2500 and 3500;

select last_name, hiredate from employee where hiredate between '01-jan-1995' and '31-dec-1995';

Select last_name, job_id from employee where job_id not in('it_prog','st_clerk','sa_rep');


*** Select the row if an employee is a president and earns more than $15,000 or if the

employee is a sales representative.

Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id, salary, commision,


manager_id, department_id from employee where (salary>=15000 and job_id in (‘pre’)) or (job_id
in('rep'));

** Display the employee id, last name and the date by annual salary

Select emp_id, last_name, hiredate from employee order by salary;

** Display the employee lastname, jobid and start date of employees hired between

February 20, 1998 and May 1, 1998 order the query in ascending order by start date

select last_name, hiredate from employee where hiredate between '01-jan-1995' and '31-dec-1995';
******************************CONTINUED

SQL PLUS OUTPUT

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Aug 13 08:15:50 2019

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Enter user-name: 18BCE0494@VITORA

Enter password:
Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table employee(

2 EMP_ID NUMBER (6) NOT NULL,

3 FIRST_NAME VARCHAR2 (20),

4 LAST_NAME VARCHAR2 (25) NOT NULL,

5 EMAIL VARCHAR2 (25) NOT NULL,

6 PHONENUMBER VARCHAR2 (15) NOT NULL,

7 HIREDATE DATE NOT NULL,

8 JOB_ID VARCHAR2 (25),

9 SALARY NUMBER (8) NOT NULL,

10 COMMISION NUMBER (4, 2),

11 MANAGER_ID NUMBER (6),

12 DEPARTMENT_ID NUMBER (4));

Table created.

SQL>

SQL> insert into employee values(14,'keerthik','keshwar','akky.reddy@gmail.com',

'98668454','26-jan-2018','45',52000,23,8,96);

1 row created.
SQL> insert into employee values(41,'lask','redy','lask.reddy@gmail.com','965988

8712','2-feb-2019','54',256000,32,6,69);

1 row created.

SQL> insert into employee values(90,'aky','red','ask.reddy@gmail.com','965988589

6','5-apr-2018','65',656000,56,8,12);

1 row created.

SQL> Select last_name, salary, salary*12+100 from employee;

LAST_NAME SALARY SALARY*12+100

------------------------- ---------- -------------

keshwar 52000 624100

redy 256000 3072100

red 656000 7872100

SQL>

SQL> select last_name, hiredate from employee where hiredate between january 199

5 and december 1995;

select last_name, hiredate from employee where hiredate between january 1995 and

december 1995

*
ERROR at line 1:

ORA-00905: missing keyword

SQL> select last_name, hiredate from employee where hiredate between '01-jan-199

5' and '31-dec-1995';

no rows selected

SQL> Select last_name, job_id from employee where job_id not in('it_prog','st_cl

erk','sa_rep');

LAST_NAME JOB_ID

------------------------- -------------------------

keshwar 45

redy 54

red 65

SQL> Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id,

salary, commision, manager_id, department_id from employee where (salary>=15000

and job_id like `%PRESIDENT%') or job_id like '%salesrepresentative%';

ERROR:

ORA-01756: quoted string not properly terminated


SQL> Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id,

salary, commision, manager_id, department_id from employee where (salary>=15000

and job_id like `%PRESIDENT%') or job_id like '%SALESREPRESENTATIVE%';

ERROR:

ORA-01756: quoted string not properly terminated

SQL> Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id,

salary, commision, manager_id, department_id from employee where (salary>=15000

and job_id like `%PRESIDENT%') or (job_id like '%REP%');

ERROR:

ORA-01756: quoted string not properly terminated

SQL> Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id,

salary, commision, manager_id, department_id from employee where (salary>=15000

and job_id in (`PRESIDENT')) or (job_id in('REP'));

ERROR:

ORA-01756: quoted string not properly terminated

SQL> Select emp_id, last_name,first_name, email, phonenumber, hiredate, job_id,

salary, commision, manager_id, department_id from employee where (salary>=15000

and job_id in (`pre')) or (job_id in('rep'));

ERROR:
ORA-01756: quoted string not properly terminated

SQL> Select emp_id, last_name, hiredate from employee where salary=624100 and sa

lary=3072100 and salary=7872100;

no rows selected

SQL>

SQL> Select emp_id, last_name, hiredate from employee where salary=52000 and sal

ary=256000 and salary=656000;

no rows selected

SQL> Select emp_id, last_name, hiredate from employee order by salary;

EMP_ID LAST_NAME HIREDATE

---------- ------------------------- ---------

14 keshwar 26-JAN-18

41 redy 02-FEB-19

90 red 05-APR-18

SQL>

You might also like