Solved

Multi part identifier could not be found

Posted on 2011-09-14
9
293 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
  • 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

747 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now