Solved

Multi part identifier could not be found

Posted on 2011-09-14
9
301 Views
Last Modified: 2012-05-12
Here is the query:
select ct.OrderTypeID,ProductName,sum(OrdersOfferedHalf) Offered,sum(OrdersHandledHalf) Handled,from Order_Type ct, Order_Type_Half_Hour cthh
left outer join cthh on Order_Type_Half_Hour.OrderTypeID = ct.OrderTypeID
where DateTime > '" & Range("testStart") & "' and DateTime < '" & Range("testEnd") &
and ct.OrderTypeID in (" & Range("queryOrderTypes") & ") ' value from excel
group by ct.OrderTypeID, ct.ProductName
order by ct.OrderTypeID

It says  The multi part identifier ct.OrderTypeID could not be found.  Please advise.
0
Comment
Question by:newone2011
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 7

Expert Comment

by:twol
ID: 36539501
Is there a field in the ORDER_TYPE table called OrderTypeID?


0
 

Author Comment

by:newone2011
ID: 36539549
Yes, there is. It was working in SQL 2000 where I had to remove the old join condition syntax for 2000 and replace with left outer join to make it work on 2005 and then got this error
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36539734
You have quotes and ampersands in the query that suggests it is being called from VB or as some other program as a dynamically generated SQL string; therefore, please post the entire code where you are setting the SQL string variable. The issue is likely in another part of the code ... although there are some type-o's in the above; however, I don't want to waste your time on those if it is a copy and paste issue given only partial code is included.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:newone2011
ID: 36539804
k, here is the entire query:

select ct.OrderTypeID, ProductName, sum(OrdersOfferedHalf) Offered, sum(OrdersHandledHalf) Handled, sum(AbandInterval1)+sum(AbandInterval2)+sum(AbandInterval3)+sum(AbandInterval4)+sum(AbandInterval5)+sum(AbandInterval6)+sum(AbandInterval7)+sum(AbandInterval8)+sum(AbandInterval9)+sum(AbandInterval10)-sum(ServiceLevelAbandHalf) Aband, sum(OrdersRONAToHalf) RONA, sum(ErrorCountToHalf) Err, sum(OrdersAnsweredToHalf) Ans, sum(HandleTimeHalf) HandleTime, sum(TalkTimeHalf) TalkTime, sum(RouterQueueWaitTimeToHalf) QWaitTime, sum(RouterQueueOrdersToHalf) QOrders, sum(ServiceLevelAbandHalf) AbandLTSL from Order_Type ct, Order_Type_Half_Hour cthh left outer join Order_Type_Half_Hour on cthh.OrderTypeID = ct.OrderTypeID where DateTime > '9/4/2011' and DateTime < dateadd(d,7,'9/4/2011') and ct.OrderTypeID in (5001,5003,5010,5012,5013,5015,5030,5032,5033,5035,5036,5037,5038,5040,5042,5043,5044,5045,5047,5048,5050,5051,5052,5053,5054,5055,5056,5057,5058,5059,5060,5061,5062,5063,5064,5065,5066,5004,5006,5362)
group by ct.OrderTypeID, ct.ProductName order by ct.OrderTypeID
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 36539827
Okay, please try with the following changes:

select ct.OrderTypeID, ProductName
     /* ... */
from Order_Type ct
left outer join Order_Type_Half_Hour cthh
   on cthh.OrderTypeID = ct.OrderTypeID

where [DateTime] > '9/4/2011' and [DateTime] < dateadd(d,7,'9/4/2011')
and ct.OrderTypeID in (5001 /*...*/)
group by ct.OrderTypeID, ct.ProductName
order by OrderTypeID
0
 

Author Comment

by:newone2011
ID: 36539840
This query was working before in 2000 with same code. The old query was. I just need to make it run on 2005: The difference between the 2 queries is highlighted in bold.

select ct.OrderTypeID, ProductName, sum(OrderOfferedHalf) Offered, sum(OrderHandledHalf) Handled, sum(AbandInterval1)+sum(AbandInterval2)+sum(AbandInterval3)+sum(AbandInterval4)+sum(AbandInterval5)+sum(AbandInterval6)+sum(AbandInterval7)+sum(AbandInterval8)+sum(AbandInterval9)+sum(AbandInterval10)-sum(ServiceLevelAbandHalf) Aband, sum(OrderRONAToHalf) RONA, sum(ErrorCountToHalf) Err, sum(OrderAnsweredToHalf) Ans, sum(HandleTimeHalf) HandleTime, sum(TalkTimeHalf) TalkTime, sum(RouterQueueWaitTimeToHalf) QWaitTime, sum(RouterQueueOrderToHalf) QOrder, sum(ServiceLevelAbandHalf) AbandLTSL from Order_Type ct, Order_Type_Half_Hour cthh where DateTime > '9/14/2011' and DateTime < dateadd(d,7,'9/14/2011') and ct.OrderTypeID *= cthh.OrderTypeID and ct.OrderTypeID in (5001,5003,5010,5012,5013,5015,5030,5032,5033,5035,5036,5037,5038,5040,5042,5043,5044,5045,5047,5048,5050,5051,5052,5053,5054,5055,5056,5057,5058,5059,5060,5061,5062,5063,5064,5065,5066,5004,5006,5362)
group by ct.OrderTypeID, ct.ProductName order by ct.OrderTypeID
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36539886
In non-ansi SQL world a *= b is a left join construct. So look at http:#a36539827 and you will see in bold what that translate to using ansi SQL joins. Make those changes to your query and see what happens, please. :)
0
 

Author Comment

by:newone2011
ID: 36539898
Seems to work, I will test more and award points by tomorrow. Thanks
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36539932
Okay, sounds good!
Best regards and happy coding,

Kevin
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question