Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Queries Help

Author  Topic 

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 00:38:17
Hello Can someone help me with this queries please

TABLE #1
EMP TABLE
Coloumns in table are
EMP_NAME
EMP_ID
MGR_ID
SALARY
GRADE
DEPT_ID

TABLE #2
DEPT TABLE
Coloumns in table are
DEPT_ID
DEPT_NAME

TABLE #3
MANAGER TABLE
Coloumns in table are
MGR_ID
MGR_NAME
DEPT_ID


The Queries are
1.Display all DEPT_NAME which consists of more than 100 employees
2.Delete all employees under MGR_NAME John Smith
3.Display the top DEPT_NAME in terms of highest salary paid to:
a.Query 1 - Individual emp
b.Query 2 - All emps
4.Display EMP_NAME & SALARY of top 10 employees in DEPT_NAME=”Manufacture”


Thanks
Alisha

Alisha

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-08 : 00:42:15
Show us what you have so far.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-08 : 01:00:39
@Alisha: I think part of an assignment .
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 01:04:34
Can some one please help me on this iam new to DB guys

Thanks

Alisha
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-08 : 01:05:59
Yes we can, however you'll have to show some effort first. We don't help with homework problems unless the person has shown some effort. Jsut copying/pasting your assignment here doesn't show us that you even tried to answer it yourself.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 01:13:20
But we dont have empno in the list of tables Yadhu.
Are you reffering to Emp_id



Alisha
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 02:13:56
Can someone please help me regarding these queries

Thanks

Alisha
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-08 : 02:18:03
yes off course ... let me know what queries you have so far the above ... i'll rectify and will make you able to get 10/10
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-08 : 03:29:04
TRY THIS


SELECT DEPT_NAME,COUNT(EMP_ID)
FROM EMP INNER JOINDEPT ON EMP.DEPTId=DEPT.DEPTId
GROUP BY DEPT_NAME
HAVING COUNT(EMPID)>100
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:30:04
Thanks yadhu very much
Thanks a lot

Alisha
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:31:02
Yha i have got it

Alisha
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:32:06
Can you help me on the other two queries also please

Display the top DEPT_NAME in terms of highest salary paid to:
a.Query 1 - Individual emp
b.Query 2 - All emps

Thanks

Alisha
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-08 : 03:35:05

TRY FOR 2nd


DELETE From
FROM EMP INNER JOIN MANAGER ON EMP.MGRID=MANEGR.MGRID
WHERE MGR_NAME='Jhon SMITH'
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:41:47
Hi

it is for each employees yadhu

Thanks

Alisha
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-08 : 03:42:33

try for 3rd

select DEPT_name ,Max(salsry) from dept inner join emp on dept.deptid=emp.deptid

group by dept_name
having max(salary)>select Max(salsry) from emp
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:46:08
Hey thanks a lot it works now

Thanks a ton yadhu

Alisha
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:47:55
Can you also help me with this one Yadhu

Display EMP_NAME & SALARY of top 10 employees in DEPT_NAME=”Manufacture”

Alisha
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 03:51:03
nope i havent

Alisha
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-08 : 03:56:31
select top 10 EMP_NAME max(sal) as sal
from emp inner join dept on emp.deptid=dept.deptid
where dept_name='manufature'
order by sal desc
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-02-08 : 04:02:11
Hey thanks a lot for your help and time.
Really you are so nice

Thanks again

Alisha
Go to Top of Page
   

- Advertisement -