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 2005 Forums
 Transact-SQL (2005)
 Multipart identifier could not be bound

Author  Topic 

Veda815
Starting Member

5 Posts

Posted - 2010-03-25 : 11:32:53
Hello - I'm wondering if anyone can spot what I am doing wrong. I have a number of subscriptions for each company that have values. I want to summarize the values of the subscriptions in my subquery so I can pass it back to the main query and then just show all my companies with the total of their subscriptions in addition to many other fields.

SELECT     C.Company_Name, C.Company_Id, RLS.Value
FROM Company AS C INNER JOIN
NDS.dbo.Registration AS R ON C.Company_Id = R.Company_Id INNER JOIN
NDS.dbo.Registration_License AS RL ON R.Registration_Id = RL.Registration_Id INNER JOIN

(select sum(subscription_value) as Value, csub.company_id from Company AS Csub INNER JOIN
Registration AS Rsub ON Csub.Company_Id = Rsub.Company_Id INNER JOIN
Registration_License AS RLsub ON Rsub.Registration_Id = RLsub.Registration_Id INNER JOIN Reg_License_Subscription as RLSsub ON RLsub.Registration_License_Id = RLSsub.Registration_License_Id
group by csub.company_id) RLS ON csub.company_Id = c.company_Id


I get this error: Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "csub.company_Id" could not be bound.

I believe it is my very last ON that is causing the problem.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-25 : 11:34:16
[code]SELECT C.Company_Name, C.Company_Id, RLS.Value
FROM Company AS C INNER JOIN
NDS.dbo.Registration AS R ON C.Company_Id = R.Company_Id INNER JOIN
NDS.dbo.Registration_License AS RL ON R.Registration_Id = RL.Registration_Id INNER JOIN

(select sum(subscription_value) as Value, csub.company_id from Company AS Csub INNER JOIN
Registration AS Rsub ON Csub.Company_Id = Rsub.Company_Id INNER JOIN
Registration_License AS RLsub ON Rsub.Registration_Id = RLsub.Registration_Id INNER JOIN Reg_License_Subscription as RLSsub ON RLsub.Registration_License_Id = RLSsub.Registration_License_Id
group by csub.company_id) RLS ON csubRLS.company_Id = c.company_Id
[/code]

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

Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-03-25 : 11:38:30
If you're using a case sensitive Collation (CS rather than CI) then things like table names, field names, and apparently aliases will also be case sensitive.

There are 10 types of people in the world, those that understand binary, and those that don't.

EDIT: Of course, if your alias name is completely wrong, then that's another matter altogether. :)
Go to Top of Page

Veda815
Starting Member

5 Posts

Posted - 2010-03-25 : 11:42:20
Thanks, Visakh. What a silly thing for me to miss. It really helps to have a second set of eyes :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-25 : 12:08:53
no problem . you're welcome

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

Go to Top of Page
   

- Advertisement -