June 16, 2009 at 9:21 am
Thanks for the help guys
June 16, 2009 at 9:39 am
#3 looks good.
For #4, what you want to do is set up a CASE statement. Are you looking for people in each group/range in one query or are you trying to get separate queries for each range?
You can do something like.
select
case
when salary = 10k and < 20k then count(employeeid)
else 0
end 'range 2'
....
June 16, 2009 at 9:53 am
Well, I've tried running 3 and this is what I get in return:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'ManagerInfo'.
On SQL Server Management Studio Express (if that matters)
For 4, what I am trying to do is similar to what you posted where it will return a table:
Range Number
1 2
2 2
3 6
Etc
Thx
June 16, 2009 at 9:57 am
check if the table 'ManagerInfo' exist?
Also see if the owner is different from you or dbo, in which case u'll need to prefix the owner name
like owner.ManagerInfo
June 16, 2009 at 10:04 am
The first post has everything I have...
June 16, 2009 at 10:20 am
I dont have sample data so cant test for logical accuracy. but the below code runs fine.
Select Emp.name,Count (ManagerInfo.EmployeeID) from Employee Emp
Join EmployeeDepartment
On Emp.EmployeeID=EmployeeDepartment.EmployeeID
Join DepartmentManager
On EmployeeDepartment.DepartmentID=DepartmentManager.DepartmentID
Join Employee ManagerInfo
On DepartmentManager.ManagerID=ManagerInfo.EmployeeID
Group by DepartmentManager.ManagerID, emp.name
Having ( Count (ManagerInfo.EmployeeID))>3
June 16, 2009 at 10:32 am
That helped a lot. Thanks!!
June 16, 2009 at 10:53 am
Thanks again for the help
June 16, 2009 at 10:59 am
case when salary >= 10000 and salary < 20000 then count(employeeid)
you need to change this everywhere.
June 16, 2009 at 11:32 am
Thanks. That got it to run.
June 16, 2009 at 11:34 am
can u post the full query? coz i cant find the table name in your query.
June 16, 2009 at 12:41 pm
Totally wrong stuff... Started over
June 16, 2009 at 1:23 pm
Ahh how can i miss that.. there is some syntax error out there....
select 'range <$10k'=
case
when salary = 10000 and salary = 20000 and salary = 30000 and salary < 40000 then count(employeeid)
end
....
....
....
....
From employee
June 16, 2009 at 2:08 pm
I'm confused. Can you please actually edit what it's supposed to say and post the first few sections EXACTLY as they should be so I can see?
Thanks
June 16, 2009 at 5:05 pm
This stuff was totally wrong too.
Viewing 15 posts - 1 through 15 (of 24 total)
You must be logged in to reply to this topic. Login to reply