You are on page 1of 53

Q: Display all records in a table.

Command: select * from emp; Output:

Q: Describe the structure of a table. Command: desc emp Output:

Q:Display the salary column of employee table. Command: select sal from emp; Output:

Q:Display annual salary of each employee. Command: select sal *12 from emp; Output:

Q:To count the number of records in a table. Command: select count(*) from emp; Output:

Q: To count distinctive department number in table. Command: select count(distinct deptno) from emp; Output:

Q: Display the record of employee whose commission is null. Command: select * from emp where comm is null; Output:

Q: Display the record of employee whose commission is not null. Command: select * from emp where comm is not null; Output:

Q: Display the record of employee whose name starts with S. Command: select * from emp where ename like 'S%'; Output:

Q: Display the record of employee whose salary is reater than !""" and he wor#s as a mana er. Command: select * from emp where sal>2000 and jo !'"#$#%&''; Output:

Q: Display the ma$imum salary in a table. Command: select ma((sal) from emp; Output:

Q: Display the minimum salary in a table. Command: select min(sal) from emp; Output:

Q: Display the avera e salary in a table. Command: select a)*(sal) from emp; Output:

Q: Display the name of employee who wor#s as a mana er and its department number is %". Command: select ename from emp where jo +!'"#$#%&'' and deptno!10; Output:

Q: Display the record of employee who &oined in the year %'(!. Command: select * from emp where hiredate like '%,2'; Output:

Q: Display the name)salary and commission of each employee. Command: select ename-sal-n)l(comm-0) from emp; Output:

Q: Display the name)salary and commission and annual salary as salary * commission of each employee. Command: select ename-sal-comm-sal.n)l(comm-0) /#nnual Salar0/ from emp; Output:

Q: Display name and &ob of each employee with wor#s as between name and &ob. Command: select ename 11 'works as' 11 jo from emp; Output:

Q: Display the record of employee whose salary lies between !""" and +""". Command: select * from emp where sal etween 2000 and 2000; Output:

Q: Display the record of employee whose department is either %" or !". Command: select * from emp where deptno in(10-20); Output:

Q: Display the record of employee who are not cler#s or mana ers. Command: select * from emp where jo not in('34&'5'-'"#$#%&''); Output:

Q: Display the record of employee ordered by their &oinin date. Command: select * from emp order 0(hiredate); Output:

Q: Display the record of employee whose department is either %" or !" and who wor#s as mana ers or cler#s. Command: select * from emp where deptno in(10-20) and jo in('"#$#%&''-'34&'5); Output:

Q: Display the record of employee whose department is neither %" nor !" and who wor#s as mana er or cler#. Command: select * from emp where deptno not in(10-20) and jo in('"#$#%&''-'34&'5'); Output:

Q: Display all the records of department table. Command: select * from dept; Output:

Q: Display the record of employee whose department no is the number of the department whose location is ,ew -or#. Command: select * from emp where deptno in (select deptno from dept where loc= 'NEW YORK'); Output:

Q: Display the record of employee who wor#s as cler# in .esearch department. Command: select * from emp where jo !'34&'5' and deptno in(select deptno from dept where dname!''&S&#'367); Output:

Q: Display the name of employee whose department no is the number of the department whose location is ,ew -or#. Command: select ename from emp where deptno in(select deptno from dept where loc!'$&8 9:'5'); Output:

Q: Display the name of employee who wor#s as cler# in /ccountin department. Command: select ename from emp where jo !'34&'5' and deptno in(select deptno from dept where dname!'#33:;$<=$%'); Output:

Q: To show operation between two tables. Command: select emp>ename-emp>jo -emp>deptno-dept>deptno-dept>dname emp-dept where emp>deptno!dept>deptno and emp>jo !'34&'5' dept>dname!'#33:;$<=$%'; Output: from and

Q: To show operation without condition. Command: emp-dept; Output: select emp>ename-emp>jo -emp>deptno-dept>deptno-dept>dname from

Q: Display the name)&ob)commission)department) department name employee)department where commission is null and in /ccountin department.

of

Command: select emp>ename-emp>jo -emp>comm-dept>deptno-emp>deptno-dept>dname from emp-dept where emp>deptno!dept>deptno and emp>comm is null and dept>dname!'#33:;$<=$%'; Output:

Q: To show all employees whose &ob is mana er.. Command: select e>empno-e>ename-m>empno-m>ename from emp e-emp m where e>empno!m>m*r; Output:

Q: Creation of a Table. Command: create table student0rno number0!1 primary #ey)name varchar0!"1)a e number0!1)cid references course12 Output:

Q: 3nsertion of records in a table. Command: insert into student values0%)/&ay)!")%"12 Output:

Q:Creation and insertion of data into ! other tables. Output:

Q: 3nsertion of data multiple times. Command: insert into student values04rno)4name)4a e)4cid1 Output:

Q: To use reference of one table into another table. Output:

Q: To drop a table Command: drop table student2 Output:

Q: To show select command. Command: select 5 from tablename2 Output:

Output:

Q: To show update command. Command: update student set attribute chan e where condition2 Output:

Q: Selectin the number of employees in the ascendin order by name. Command:>select * from emp order 0 ename; Output:

Q: To show all the records in descendin order of name.

Command: Select * from emp order 0 ename desc; Output:

Q: 6ultiple conditions in order by command. Command: select * from emp order 0 ename-jo ; Output:

Q: 6ultiple conditions in order by command in descendin order. Command: select * from emp order 0 ename-jo desc; Output:

Q: To display lower characters and initial capital characters. Output:

Q: To display upper characters and initial capital characters. Output:

Q: To show concatenation command) Command: select concat(?)archar17-7)archar27) from dual; Output:

Q: To show left and ri ht paddin . Output:

Q: To show round command. Output:

Q: To show truncate command. Output:

Q: To show round command where precision is ne ative. Command: Select round(122>@A,-B1) from dual; Output:

Command: Select round(122>@A,-B2) from dual; Output:

Q: To show modulus command. Command: Select mod(12-2) from dual; Output:

Q: To ive a column name to our value. Output:

Q: To show add7months command in dual table. Command: select addCmonths(s0sdate-@) from dual; Output:

Q: To show ne$t7day command in dual table. Command: select ne(tCda0(722B:3<B20127-7tuesda07) from dual; Output:

Q: To show last7day command in dual table. Command: select lastCda0(701BdecB20127) from dual; Output:

You might also like