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

Explain steps of normalization?

525


What do you mean by sql server agent?

537


What are the purposes and advantages stored procedure?

495


Explain the various types of concurrency problem. I.e. Lost or buried updates, uncommitted dependency, inconsistent analysis, phantom read?

497


Are all views updatable ?

718






what are defaults? Is there a column to which a default can't be bound? : Sql server database administration

616


How to modify existing triggers using "alter trigger"?

522


Can I save my report as html, excel or word? : sql server management studio

541


how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }

1844


What are the main differences between #temp tables and @table variables and which one is preferred?

547


List the types of recovery model available in sql server?

501


How to list all dsn entries on your local machine using odbc_data_source()?

553


How to use transact-sql statements to access the database engine?

537


What is enhanced database mirroring in sql server 2008?

513


What is merge statement?

623