Database Management Systems (3130703) MCQs

MCQs of SQL Concepts

Showing 21 to 30 out of 68 Questions
21.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

DISPLAY THE HIGHEST, LOWEST, TOTAL, AND AVERAGE SALARY OF ALL EMPLOYEES. LABEL THE COLUMNS MAXIMUM, MINIMUM, TOTAL_SAL AND AVERAGE_SAL, RESPECTIVELY.

(a)

SELECT MAXIMUM(SALARY) AS MAXIMUM, MIN(SALARY) AS MINIMUM, SUM(SALARY) AS TOTAL_SAL, AVERAGE(SALARY) AS AVERAGE_SAL FROM EMPLOYEE

(b)

SELECT MAXIMUM(SALARY) AS MAXIMUM, MINIMUM(SALARY) AS MINIMUM, SUM(SALARY) AS TOTAL_SAL, AVG(SALARY) AS AVERAGE_SAL FROM EMPLOYEE

(c)

SELECT MAX(SALARY) AS MAXIMUM, MIN(SALARY) AS MINIMUM, SUM(SALARY) AS TOTAL_SAL, AVG(SALARY) AS AVERAGE_SAL FROM EMPLOYEE

(d)

SELECT MAXIMUM(SALARY) AS MAXIMUM, MIN(SALARY) AS MINIMUM, SUM(SALARY) AS TOTAL_SAL, AVG(SALARY) AS AVERAGE_SAL FROM EMPLOYEE

Answer:

Option (c)

22.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

FIND TOTAL NUMBER OF EMPLOYEES OF EMPLOYEE TABLE.

(a)

SELECT CHECK (ENAME) "TOTAL NO OF EMPLOYEE" FROM EMPLOYEE

(b)

SELECT COUNT ALL (ENAME) "TOTAL NO OF EMPLOYEE" FROM EMPLOYEE

(c)

SELECT COUNT OF (ENAME) "TOTAL NO OF EMPLOYEE" FROM EMPLOYEE

(d)

SELECT COUNT(ENAME) "TOTAL NO OF EMPLOYEE" FROM EMPLOYEE

Answer:

Option (d)

23.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

GIVE MAXIMUM SALARY FROM IT DEPARTMENT.

(a)

SELECT MAXIMUM(SALARY) AS MAXIMUM FROM EMPLOYEE WHERE DEPARTMENT='IT'

(b)

SELECT MAX(SALARY) AS MAXIMUM FROM EMPLOYEE WHERE DEPARTMENT='IT'

(c)

SELECT MAX(SALARY) AS MAXIMUM FROM EMPLOYEE TABLE WHERE DEPARTMENT='IT'

(d)

SELECT MAXIMUM(SALARY) AS MAXIMUM FROM EMPLOYEE TABLE WHERE DEPARTMENT='IT'

Answer:

Option (b)

24.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

COUNT TOTAL NUMBER OF CITIES OF EMPLOYEE WITHOUT DUPLICATION.

(a)

SELECT COUNT(DIFFERENT CITY) "TOTAL CITY" FROM EMPLOYEE

(b)

SELECT COUNT(DISTINCT CITY) "TOTAL CITY" FROM EMPLOYEE

(c)

SELECT COUNT(UNIQUE CITY) "TOTAL CITY" FROM EMPLOYEE

(d)

SELECT COUNT(ALL CITY) "TOTAL CITY" FROM EMPLOYEE

Answer:

Option (b)

25.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

DISPLAY CITY WITH THE TOTAL NUMBER OF EMPLOYEES BELONGING TO EACH CITY.

(a)

SELECT CITY, COUNT(ENAME) FROM EMPLOYEE GROUP BY ENAME

(b)

SELECT CITY, COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY

(c)

SELECT CITY, COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY, ENAME

(d)

SELECT COUNT(CITY), COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY, ENAME

Answer:

Option (b)

26.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

DISPLAY CITY HAVING MORE THAN ONE EMPLOYEES.

(a)

SELECT CITY AND COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY HAVING COUNT(ENAME)>1

(b)

SELECT CITY,COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY HAVING TOTAL(ENAME)>1

(c)

SELECT CITY,COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY HAVING COUNT(ENAME)>1

(d)

SELECT CITY,COUNT(ENAME) FROM EMPLOYEE GROUP BY CITY WHOSE COUNT(ENAME)>1

Answer:

Option (c)

27.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

GIVE TOTAL SALARY OF EACH DEPARTMENT OF EMPLOYEE TABLE.

(a)

SELECT DEPARTMENT,SUM(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

(b)

SELECT DEPARTMENT, TOTAL(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

(c)

SELECT COUNT(DEPARTMENT), SUM(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

(d)

SELECT SUM(DEPARTMENT), SUM(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

Answer:

Option (a)

28.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

GIVE AVERAGE SALARY OF EACH DEPARTMENT OF EMPLOYEE TABLE WITHOUT DISPLAYING THE RESPECTIVE DEPARTMENT NAME.

(a)

SELECT AVERAGE(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

(b)

SELECT AVG(SALARY) FROM EMPLOYEE GROUP BY DEPARTMENT

(c)

SELECT AVERAGE(SALARY) FROM EMPLOYEE JOIN BY DEPARTMENT

(d)

SELECT AVERAGE(SALARY) FROM EMPLOYEE SET BY DEPARTMENT

Answer:

Option (b)

29.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

LIST THE DEPARTMENTS HAVING TOTAL SALARIES MORE THAN 50000 AND LOCATED IN CITY RAJKOT.

(a)

SELECT DEPARTMENT,SUM(SALARY) FROM EMPLOYEE WHERE CITY='RAJKOT' GROUP BY DEPARTMENT HAVING SUM(SALARY)>50000

(b)

SELECT DEPARTMENT,TOTAL(SALARY) FROM EMPLOYEE WHERE CITY='RAJKOT' GROUP BY DEPARTMENT HAVING SUM(SALARY)>50000

(c)

SELECT DEPARTMENT,SUM(SALARY) FROM EMPLOYEE WHOSE CITY='RAJKOT' GROUP BY DEPARTMENT HAVING SUM(SALARY)>50000

(d)

SELECT DEPARTMENT,SUM(SALARY) FROM EMPLOYEE WHERE CITY='RAJKOT' GROUP BY DEPARTMENT WHOSE SUM(SALARY)>50000

Answer:

Option (a)

30.

Write SQL statements (Query) for following tables:

Employee(EID, EName, Department, Salary, JoiningDate, City)

LIST OUT DEPARTMENT NAMES IN WHICH MORE THAN TWO EMPLOYEES.

(a)

SELECT DEPARTMENT FROM EMPLOYEE GROUP BY DEPARTMENT HAVING COUNT(ENAME)=2

(b)

SELECT DEPARTMENT FROM EMPLOYEE JOIN BY DEPARTMENT HAVING COUNT(ENAME)>2

(c)

SELECT DEPARTMENT FROM EMPLOYEE GROUP BY DEPARTMENT HAVING COUNT(ENAME)>2

(d)

SELECT DEPARTMENT FROM EMPLOYEE GROUP BY DEPARTMENT WHOSE COUNT(ENAME)>2

Answer:

Option (c)

Showing 21 to 30 out of 68 Questions