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

What are commit and rollback in sql?

738


Does the unique constraint create an index?

739


Explain transaction isolation levels in sql server?

736


Do you know clustered and non-clustered index?

724


Does union all remove duplicates?

797






What are the security related catalog views? : sql server security

695


How does clustered and non clustered index work?

677


What new changes are being made in SQL Server?

773


How do you test your database? : sql server database administration

710


How to get a list of columns using the "sp_help" stored procedure in ms sql server?

749


How do I trace a query in sql server?

695


What is the difference between a "where" clause and a "having" clause?

825


Can you use order by when defining a view?

724


What is reference section?

664


Do you know what are the steps to process a single select statement?

701