Wednesday, 5 September 2012

Given the following table definition: | System Administration

STAFF
id INTEGER
name CHAR20.
dept INTEGER
job CHAR20.
years INTEGER
salary DECIMAL10,2.
comm DECIMAL10,2.
Which of the following SQL statements will return a result set that satisfies these conditions:
-Displays the department ID and total number of employees in each department.
-Includes only departments with at least one employee receiving a commission comm. greater than 5000.
-Sorted by the department employee count from greatest to least.
A. SELECT dept, COUNT*. FROM staff GROUP BY dept HAVING comm > 5000 ORDER BY 2 DESC
B. SELECT dept, COUNT*. FROM staff WHERE comm > 5000 GROUP BY dept, comm ORDER BY 2 DESC
C. SELECT dept, COUNT*. FROM staff GROUP BY dept HAVING MAXcomm. > 5000 ORDER BY 2 DESC
D. SELECT dept, comm, COUNTid. FROM staff WHERE comm > 5000 GROUP BY dept, comm ORDER BY 3 DESC

Ans : C


No comments: