Display each employee s name and date of joining. Display employees earning more than Rs.5,000. Label the column name employee. Ans: select emp_name AS EMPLOYEE FROM EMP where salary>5000.00.
Display each employee s name and date of joining. Display employees earning more than Rs.5,000. Label the column name employee. Ans: select emp_name AS EMPLOYEE FROM EMP where salary>5000.00.
Direitos autorais:
Attribution Non-Commercial (BY-NC)
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia online no Scribd
Display each employee s name and date of joining. Display employees earning more than Rs.5,000. Label the column name employee. Ans: select emp_name AS EMPLOYEE FROM EMP where salary>5000.00.
Direitos autorais:
Attribution Non-Commercial (BY-NC)
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia online no Scribd
EMP_NAME VARCHAR(25) DESIGNATION CHAR(4) JOINING_DATE DATE SALARY NUMBER(7,2) DEPT_NO NUMBER(2) DEPT DEPT_NO NOT NULL NUMBER(2) DEPT_NAME VARCHAR(25) BUDGET NUMBER(15,2) MANAGER VARCHAR(25) ans: Query to create EMP table: CREATE TABLE EMP ( emp_no NUMERIC(4) NOT NULL, emp_name VARCHAR(25), designation CHAR(4), joining_date DATE, salary NUMERIC(7,2), dept_no NUMERIC(2), PRIMARY KEY (emp_no) ) Query to create DEPT table: CREATE TABLE dept ( dept_no NUMERIC(2,0) NOT NULL, dept_name VARCHAR(25), budget NUMERIC(15,2), manager VARCHAR(25), PRIMARY KEY (dept_no), CONSTRAINT FK_dept_1 FOREIGN KEY FK_dept_1 (dept_no) REFERENCES emp (dept_no) ) INSERTION or MODIFICATION OF DATA Into EMP table: insert into EMP values(&emp_no,&emp_name,&designation, &joining_date,&salary,&dept_no) INSERTION or MODIFICATION OF DATA Into DEPT table: insert into DEPT values(&dept_no,&dept_name,&budget,&manager) SQL queries for the following : 1. Display each employee s name and date of joining. ans: select emp_name,joining_date FROM EMP; 2. Display employees earning more than Rs.5,000. Label the column name Employee . ans: select emp_name AS EMPLOYEE FROM EMP where salary>5000.00; 3. Display all employee names and employee numbers in the alphabetical order of names. ans: select emp_name,emp_no FROM EMP order by emp_name; 4. Display all employee names containing the letter S . ans: select emp_name from EMP where emp_name like '%s%' 5. Display the employees hired in 1981. ans: select emp_no,emp_name from emp where joining_date like '%1981%' 6. Display the minimum and maximum salary. ans: select MAX(salary)AS MAXSAL,MIN(salary)AS MINSAL FROM EMP; 7. Display the list of employees along with their department name and its manage r. ans: select emp_name,dept_name,manager from EMP,DEPT where EMP.dept_no=DEPT.dept_no; 8. Display the number of different employees listed for each department. ans: Select dept_name,count(distinct emp_name) from EMP,DEPT where EMP.dept_no=DEPT.dept_no group by dept_name; 9. Delete the records of all the employees hired in 1981 from EMP table. ans: delete from EMP where date like '%1981%'; 10. Update the salary of all the employees to Rs. 10,000. ans: update EMP set salary=10000;