Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Help,,,please

Status
Not open for further replies.

gtb12314

Programmer
Jan 7, 2008
41
US
Hi All,

I want to write a query to find out which employees have multiple PTO plans and also who has multiple employee groups (database.employee_group)

I am writing a query against one table which has field (database.plan) for plan names and (database.employee_group )for employee groups.

Any help is greatly appeciated.

Thanks in advance!!
 

- NO Table definitions
- NO Sample data
- NO Code
= NO help
[thumbsdown]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
I am sorry, here is my code:

select employee,r_plan,count(*) as TotalPTOPlans
from lawson.taeemaster
where r_plan='PTO'
group by employee,r_plan
having count(*)>1
 
So, GTB,

What problem would you like us to help with? What is the outcome of running the code that you posted, above?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
A fo ben, bid bont.
 
my question is I want to find out the employees who has more than one PTO plan and more than one employee group(table.employee_group)

So I think my query is bringing employees with multiple PTO plans but not with multiple employee groups.How to write a query for this. Also I want to make sure that my sql command is correct.

Please help me.
 
LKBrwnDBA said:
- NO Table definitions
- NO Sample data...
LK is correct...It makes it rather difficult to help if you make us guess what your data looks like, and, if you make us guess what you want the output to look like.

GTB said:
So I think my query is bringing employees with multiple PTO plans but not with multiple employee groups.
Since you haven't posted what you want the output to look like, I've posted some code that I am guessing shows the multiple employee groups:
Code:
select employee
      [b],employee_group[/b]
      ,r_plan
      ,count(*) as TotalPTOPlans 
from lawson.taeemaster
where r_plan='PTO'
group by employee,[b]employee_group,[/b]r_plan
having count(*)>1;
Let us know if we are getting warmer. (And if we're not getting warmer, please post a sample of what you want for output.)

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
A fo ben, bid bont.
 
Below is the output from my sql command. Now I want to see whether these employees have multiple Employee group(talbe.employee_group) or not.

EMPLOYEE R_PLAN TOTALPTOPLANS
3461852 PTO 2
3399292 PTO 2
390765 PTO 2
165076 PTO 2
87270 PTO 2
492298 PTO 2
253948 PTO 2
112060 PTO 2
515874 PTO 2
174904 PTO 2
3346228 PTO 2
3353174 PTO 2
55434 PTO 2
310250 PTO 2
3401015 PTO 2
88591 PTO 2
93591 PTO 2
3159290 PTO 2
3480134 PTO 2
26443 PTO 2
392308 PTO 2
86181 PTO 2
3413465 PTO 2
3458866 PTO 2
294546 PTO 2
3450574 PTO 2

Mufasa thanks for your help!

 
GTB said:
Mufasa thanks for your help!
As I mentioned earlier, I don't feel like I am providing as much help as I could be providing...Please post a sample of output you would like to see!

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
A fo ben, bid bont.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top