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 / mahesh

Hi dear,
1) If you have need name of total salary of each department to spend on employee(Understand like this) then use query:
select deptname, SUM(salary)
from Department
GROUP BY deptname
HAVING SUM(salary) >= 5000;

2) Otherwise

SELECT deptname
FROM Department
WHERE salary >= 5000;

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how many triggers you can have on a table? : Sql server database administration

487


What is the difference between coalesce() & isnull()?

530


What is the report builder?

106


how to control the amount of free space in your index pages? : Sql server database administration

596


What is a primary index?

520






What is the difference between nvl and nvl2?

547


How to count duplicated values in a column in ms sql server?

514


what's sql server? : Sql server database administration

494


Difference between DELETE and TRUNCATE?

613


What is CTE in SQL

538


You are creating an application where users are asked their gender in the gender combo box you have three options: ‘male’ , ‘female’ and ‘i choose not to disclose’ these options are stored in the table as 1, 0 or null which datatype should you use?

543


how to restart sql server in single user mode? How to start sql server in minimal configuration mode? : Sql server database administration

458


how to avoid cursors? : Sql server database administration

491


What are the steps to take to improve performance of a poor performing query? : sql server database administration

598


what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration

553