Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Ques No.1Consider the following tables FACULTY and COURSES. Write SQL commands
for the statements (i) to (iv)
Ques No.2Consider the following tables EMPLOYEE and SALARY and write SQL
commands for the questions (i) to (iv)
i) To display the name of all employees who are in the electrical department having more than 8
years of experience from the EMPLOYEES table.
ii) To display the average salary of all the employees in IT department using both the above
tables. (Hint: Salary = Basic + DA +Allowance)
iii) To display the minimum DA for the female employee.
iv) To display the name, basic, DA of the employee from the HR department.
ANSWERS:
i)SELECT Name FROM EMPLOYEES WHERE DEPT=ELECTRICALAND Experience > 8
ii) SELECT BASIC+DA+ALLOWANCE AVG SALARY FROM EMPLOYEES E,SALARY
S WHERE E.EMPID=S.EMPID AND DEPT=IT
iii)SELECT MIN(DA) FROM EMPLOYEES E, SALARY S WHERE E.EMPID = S.EMPID
AND GENDER=F
iv)SELECT NAME,BASIC,DA FROM EMPLOYEES E, SALARY S WHERE E.EMPID =
S.EMPID AND DEPT = HR
Ques No.3Consider the DEPT and WORKER table. Write SQL queries for (i) to (iv):
(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno.
(ii) To display the Name of all the FEMALE workers from the table WORKER.
(iii) To display the Wno and Name of those workers from the table WORKER who are born
between 1987-01-01 and 1991-12-01.
(iv) To count and display MALE workers who have joined after 1986-01-01.
ANSWERS:
(i) SELECT WNO, NAME, GENDER FROM WORKER ORDER BY WNO desc
(ii) SELECT NAME FROM WORKER WHERE GENDER = FEMALE
(iii) SELECT WNO, NAME FROM WORKER WHERE DOB BETWEEN 1987-01-01 AND
1991-12-01
(iv) SELECT COUNT(*) FROM WORKER WHERE GENDER=MALE AND DOJ >
1986-01-01
Ques No.4Write SQL commands for the queries (i) to (iv) based on a table COMPANY and
CUSTOMER.
(i)To display
the count of
companies in the city and city name.
(ii) To display the name of the companies in reverse alphabetical order.
(iii) To increase the price by 1000 for those customer whose name starts with S.
(iv)To display the product name, city and price from the table of product MOBILE.
ANSWERS:
(i)SELECT COUNT(*) ,CITY FROM COMPANY GROUP BY CITY
(ii) SELECT NAME FROM COMPANY ORDER BY NAME desc
(iii) UPDATE CUSTOMER SET PRICE=PRICE + 1000 WHERE NAME LIKE S%
(iv) SELECT PRODUCTNAME, CITY, PRICE FROM COMPANY, CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=MOBILE
Ques No.5Write SQL commands for the queries (i) to (iv) based on a table SHOPPE and
ACCESSORIES.
(i) To display Name and Price of all the Accessories in ascending order of their Price.
(ii) To display Id and SName of all Shoppe located in Nehru Place.
(iii) To display Minimum and Maximum Price of each Name of Accessories.
(iv) To display Name, Price of all Accessories and their respective SName and where they are
available.
ANSWERS:
(i) SELECT NAME, PRICE FROM ACCESSORIES ORDER BY PRICE
(ii) SELECT Id, Sname FROM SHOPPE WHERE AREA=Nehru Place
(iii) SELECT MIN(PRICE), MAX(PRICE) FROM ACCESSORIES GROUP BY NAME
(iv) SELECT NAME, PRICE, SNAME, AREA FROM ACCESSORIES A, SHOPPE S WHERE
A.ID = S.ID