adspace


i need to know how i display department which has salary >
=5000 for the below table
Department
-----------
salary deptname
1000 a
3000 a
2000 b
3000 b
4000 c
5000 c

kindly send the query to thilakvinoth13@gmail.com

Answer Posted / sahil

The query will be to get the total of salary >= 5000 in a
department is :


select deptname, sum (salary) as totalsalary from Department
group by deptname

then it will shown like

deptname total salary
a 4000
b 5000
c 9000

now we will get the highest total salary from department
remember group by is always used to group-set.

select deptname, sum (salary) from Department
group by deptname
having sum (salary) >= 5000

Then you will get the answer!!

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

do you know how to configure db2 side of the application? : Sql server database administration

1123


what is spatial nonclustered index

1057


How do I start sql server 2017?

1015


When should you use an instead of trigger?

1051


How can I check that whether automatic statistic update is enabled or not?

1111


What is temporary table in sql server? Why we use temp table?

1019


Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?

1022


Why use identity in sql server?

1196


What is the difference between upgrade and migration in sql server?

1183


What is the difference between for xml raw and for xml auto?

1114


How to remove duplicate rows from table except one?

1087


What are the pros and cons of putting a scalar function in a queries select list or in the where clause?

1298


Is it possible to have clustered index on separate drive from original table location?

1039


What are different types of constraints?

1000


How do I create a trace in sql server?

1118