1,793 views
3 votes
3 votes

Consider the set of relations

  • EMP (Employee-no. Dept-no, Employee-name, Salary)
  • DEPT (Dept-no. Dept-name, Location)

Write an SQL query to:

Calculate, for each department number, the number of employees with a salary greater than Rs. 1,00,000

3 Answers

5 votes
5 votes
SELECT Dept-no, count(Employee-no) as total_employees
FROM EMP
WHERE Salary > 100000
GROUP BY Dept-no
2 votes
2 votes
select Dept-no, count(*)

from EMP group by Dept-no having salary > 100000

Related questions

39 votes
39 votes
2 answers
2
Kathleen asked Sep 23, 2014
19,636 views
Which of the following is/are correct?An SQL query automatically eliminates duplicatesAn SQL query will not work if there are no indexes on the relationsSQL permits attri...
25 votes
25 votes
1 answer
3
Kathleen asked Sep 23, 2014
4,009 views
Let $R = (A, B, C, D, E, F)$ be a relation scheme with the following dependencies $C \rightarrow F, E \rightarrow A, EC \rightarrow D, A \rightarrow B $. Which one of the...
38 votes
38 votes
1 answer
4
Kathleen asked Sep 23, 2014
16,790 views
Consider the join of a relation $R$ with a relation $S$. If $R$ has $m$ tuples and $S$ has $n$ tuples then the maximum and minimum sizes of the join respectively are$m+n$...