Create table emp with attributes (eid number,ename varchar2(10),age number,salary number)

Create table emp with attributes (eid number,ename varchar2(10),age number,salary number)

  1. Count number of employee names from employee table.
  2. Display the Sum of age employee table.
  3. Find grouped salaries of employees.(group by clause).
  4. Find salaries of employee in Ascending Order.(order by clause).
  5. Find salaries of employee in Descending Order.
Answer:

Command for Creation of Table:

CREATE TABLE EMP (EID_NUMBER NUMBER, ENAME VARCHAR2(10), AGE NUMBER, SALARY NUMBER);


Command for inserting data into table:

INSERT INTO EMP VALUES (101,'Anu', 22 , 9000); INSERT INTO EMP VALUES (102,'Shane', 29 , 8000); INSERT INTO EMP VALUES (103,'Rohan', 34 , 6000); INSERT INTO EMP VALUES (104,'Scott', 44 , 10000); INSERT INTO EMP VALUES (105,'Tiger', 35 , 8000); INSERT INTO EMP VALUES (106,'Alex', 27 , 7000); INSERT INTO EMP VALUES (107,'Abhi', 29 , 8000);


1.
SELECT COUNT(ENAME) FROM EMP;


2.
SELECT SUM(AGE) FROM EMP;


3.
SELECT COUNT(EID_NUMBER), SALARY FROM EMP GROUP BY SALARY;


4.
SELECT * FROM EMP ORDER BY SALARY ASC;


5.
SELECT * FROM EMP ORDER BY SALARY DESC;



Comments