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)
 Nested Inner Joins with SubSelects

Author  Topic 

wooddsw
Starting Member

1 Post

Posted - 2010-12-15 : 21:03:30
I would appreciate any suggestions on the following code and why I'm getting the following error message:
Msg 8156, Level 16, State 1, Line 14
The column 'added_by' was specified multiple times for 'A'.

Code

select *
from sfdc..contact C
inner join
(
select * from avenue2..activity G
inner join (
select e.added_by, COUNT(*) as 'TotalActivities'
from avenue2..activity E
where ACTIVITY_DATE between '2008-01-01'
and '2010-12-31'
group by E.added_by
having COUNT(*) > 0
)
B on G.ADDED_BY = B.ADDED_BY
where G.Activity_Date between '2008-01-01' and '2010-12-31'
)
A on C.retire_stamp2__C = A.Contact_stamp2
where A.date_added between '2010-01-02' and '2010-01-31'

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-15 : 22:27:09
Just a guess:
quote:

(
select * from avenue2..activity G
inner join (
select e.added_by, COUNT(*) as 'TotalActivities'
from avenue2..activity E
where ACTIVITY_DATE between '2008-01-01'
and '2010-12-31'
group by E.added_by
having COUNT(*) > 0
)




The table avenue2..activity G may be having a column with name added_by.

The output of avenue2..activity G and avenue2..activity E together is placed in derived table A. So you now two columns with same name.

Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -