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)
 Ambiguous column name

Author  Topic 

brad_81x
Starting Member

8 Posts

Posted - 2012-08-03 : 05:30:51
Hi people,

Can anyone spot the error here and advise how I can change... Friday morning blonde moment:

CODE:

select l.id as [eSales Lead ID],l.company_id as [eSales Company ID], l.company_name_txt as [Company Name], c.address_line_1_txt, c.city_txt, c.state_cd, c.zip_cd, c.country_cd,
l.source_cd as [Source Treatment Code], l.created_on_dt,
l.last_update_dt,l.qsl_accept_dt,l.pass_to_sales_dt,l.status_cd, l.pts_by_txt,
l.assigned_to_txt,a.img_role_cd,l.sales_region_cd,l.sales_subregion_cd,lkp.text_string as [Globals Classification],
l.type_cd, l.segment_cd
from lead_d l
join company_d c on c.id=l.Company_id
join agent a on a.agent_name = l.assigned_to_txt
join lookup lkp_2 on lkp_2.code_string=c.unit_cd and lookup_category_name = 'esfa_globals_lkp'
join lookup lkp on lkp.code_string=a.img_business_unit_lkp and lookup_category_name = 'img_business_unit'

where l.status_cd in ('active','hraise','new','pend','overdue')
and l.pass_to_sales_dt is NULL and type_cd = 'market'
and l.obsolete_flag = 0 and c.obsolete_flag = 0
and c.unit_cd in ('GLOBALS_>_250M','GLOBALS_OVERRIDE')

ERROR:

Msg 209, Level 16, State 1, Line 10
Ambiguous column name 'lookup_category_name'.

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-08-03 : 05:43:02
select l.id as [eSales Lead ID], l.company_id as [eSales Company ID],
l.company_name_txt as [Company Name], c.address_line_1_txt, c.city_txt,
c.state_cd, c.zip_cd, c.country_cd,
l.source_cd as [Source Treatment Code], l.created_on_dt,
l.last_update_dt, l.qsl_accept_dt, l.pass_to_sales_dt, l.status_cd,
l.pts_by_txt, l.assigned_to_txt, a.img_role_cd, l.sales_region_cd,
l.sales_subregion_cd, lkp.text_string as [Globals Classification],
l.type_cd, l.segment_cd
from lead_d l
join company_d c on c.id = l.Company_id
join agent a on a.agent_name = l.assigned_to_txt
join lookup lkp_2 on lkp_2.code_string = c.unit_cd
and lkp_2.lookup_category_name = 'esfa_globals_lkp'
join lookup lkp on lkp.code_string = a.img_business_unit_lkp
and lkp.lookup_category_name = 'img_business_unit'
where l.status_cd in ( 'active', 'hraise', 'new', 'pend', 'overdue' )
and l.pass_to_sales_dt is NULL
and type_cd = 'market'
and l.obsolete_flag = 0
and c.obsolete_flag = 0
and c.unit_cd in ( 'GLOBALS_>_250M', 'GLOBALS_OVERRIDE' )



--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

brad_81x
Starting Member

8 Posts

Posted - 2012-08-03 : 05:50:21
ah!!

cheers lionofdezert :)
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-08-03 : 13:51:24


--------------------------
http://connectsql.blogspot.com/
Go to Top of Page
   

- Advertisement -