The Gateway to Computer Science Excellence
+2 votes
1.8k views

Consider the following schema:

Emp (Empcode, Name, Sex, Salary, Deptt)

A simple SQL query is executed as follows:

SELECT Deptt FROM Emp

GROUP by Dept

Having avg (Salary) > {select avg (Salary) from Emp}

The output will be

  1. Average salary of male employee is the average salary of the organization
  2. Average salary of male employee is less than the average salary of the organization
  3. Average salary of male employee is equal to the average salary of the organization
  4. Average salary of male employee is more than the average salary of the organization
in Databases by Veteran (105k points) | 1.8k views
+1

select deptName  from Employee  
where sex = 'Male'  \\ $ \color{Red}{Line \ is \ missing \ in \ question}!$
group by deptName 
having avg (salary) >   (select avg (salary) from Employee)

0
I guess the question setter doesn't know English properly..! :)

Isro SQL questions are more based on verbal than dbms..

PEACE

1 Answer

+7 votes

Answer : D

Average salary of male employee is more than the average salary of the organization

select deptName 
from Employee 
where sex = 'Male'
group by deptName
having avg (salary) >   
(select avg (salary) from Employee)

Here we are going to get the name of all departments in which the average salary of male employees is greater than the average salary of all employees in the company. 

by Boss (45.4k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,297 answers
198,265 comments
104,977 users