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)
 Is this possible with outer join

Author  Topic 

baze7
Yak Posting Veteran

58 Posts

Posted - 2010-03-16 : 09:57:08
With a outer join, is it possible to combined records onto one?

I will try to explain:
left outer join (
select distinct count(emp_num) as EmpCount,emp_num from employee
group by emp_num) as emp on emp.emp_num = jobtran.emp_num

If this returns, lets say 2 different emp_num, let say 2 and 5 could I have it combined to 2 and 5 into 1 column (for lack of better term)

Does that make sense?

So my record set could look something like:

1 1,2
2 1,2


Thanks
Chad

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-16 : 10:03:35
what does that mean? do you mean showing counts for 2 ids on same column?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

baze7
Yak Posting Veteran

58 Posts

Posted - 2010-03-16 : 10:08:27
Yes
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-16 : 10:13:50
whats the need for that? what sense does it make to show two counts of unrelated ids in single column ?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

baze7
Yak Posting Veteran

58 Posts

Posted - 2010-03-16 : 10:18:12
I am running a trigger and I am emailing the results. I have all information emailing like I need it, but when there are mutiple emp_nums, I want that included in the email. The emp_num is the only return that could have multiple recordsets. Maybe there is a different way to do what I am trying to do? That help at all?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-16 : 10:20:32
even in that case isnt it better to mail it like below

emp_num count

1000 15
1023 44

...

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

baze7
Yak Posting Veteran

58 Posts

Posted - 2010-03-16 : 10:22:50
We want to see the employee number in the email
Go to Top of Page

baze7
Yak Posting Veteran

58 Posts

Posted - 2010-03-16 : 10:29:08
OK, I see what you are saying, yes but I am not sure how to do that in my code. Would it help if I post my code?
Go to Top of Page

nhess80
Yak Posting Veteran

83 Posts

Posted - 2010-03-17 : 15:52:35
Can you post your code and some sample data and an example of the result you are looking for?
Go to Top of Page
   

- Advertisement -