| |
Welcome to the dBforums forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact support.
If you prefer not to see double-underlined words and corresponding ads, place your cursor here for ContentLink opt out.
|
 |

09-30-04, 13:37
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 37
|
|
|
Please Help
|
I am creating a query and am getting:
"Data Type Mismatch in criteria expression" error messages!!
It's driving me crazy. It only happens when I enter certain codes. For example, if I enter "2AP" the query works. If i enter "2AK", I receive the error!
Here is the SQL although I used Design View in Access to create the query:
SELECT TradeHist.[Portfolio Code], Sum([Trade Shares]*[Trade FX Rate]*[Order Decision Price]) AS MV, Sum([Trade Shares]*[Trade FX Rate]*[Order Decision Price]*[OrderHor])/[MV] AS OHMV, Sum(IIf([OrderHor]>=0.5,1,0)*[Trade Shares]*[Trade FX Rate]*[Order Decision Price])/[MV] AS PercOverFifty
FROM OrderHorizonQuery INNER JOIN TradeHist ON OrderHorizonQuery.[Order ID Master] = TradeHist.[Order ID Master]
GROUP BY TradeHist.[Portfolio Code]
HAVING (((TradeHist.[Portfolio Code])="2AK" Or (TradeHist.[Portfolio Code])="42O" Or (TradeHist.[Portfolio Code])="4UZ"));
Any help would be appreciated!
|
|

09-30-04, 16:01
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
|
|
put your conditions into the WHERE clause
Code:
select TradeHist.[Portfolio Code]
, Sum([Trade Shares]*[Trade FX Rate]*[Order Decision Price]) AS MV
, Sum([Trade Shares]*[Trade FX Rate]*[Order Decision Price]*[OrderHor])/[MV] AS OHMV
, Sum(IIf([OrderHor]>=0.5 ,1 ,0)*[Trade Shares]*[Trade FX Rate]*[Order Decision Price])/[MV] AS PercOverFifty
from OrderHorizonQuery
inner
join TradeHist
on OrderHorizonQuery.[Order ID Master]
= TradeHist.[Order ID Master]
where TradeHist.[Portfolio Code] in ('2AK','42O','4UZ')
group
by TradeHist.[Portfolio Code]
|
|

09-30-04, 17:42
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 37
|
|
|
Thanks for the effort but It is still yeilding the same error. any other ideas?
|
|

09-30-04, 17:51
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
|
|
double-check the datatypes of all columns involved
|
|

09-30-04, 23:53
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 37
|
|
How will I identify mistakes after looking at the data types of each column involved in the query? Thanks again for your continued support!

|
|

10-01-04, 00:30
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 1
|
|
(((TradeHist.[Portfolio Code]='2AK') Or (TradeHist.[Portfolio Code]='42O') Or (TradeHist.[Portfolio Code])='4UZ'));
Try this
__________________
rgds
Roshu
|
|

10-01-04, 01:06
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,570
|
|
Quote:
|
Originally Posted by gissa
How will I identify mistakes after looking at the data types of each column involved in the query? Thanks again for your continued support!

|
Based on your posted code, [OrderHor] should be a numeric type, and [Portfolio Code] should be a text type. I'd guess that one of them is of the wrong type.
-PatP
|
|

10-01-04, 07:49
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 37
|
|
Thanks all. Ill be at work in a bit. Ill let you know what I find!!!
|
|

10-01-04, 16:23
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 37
|
|
|
|

10-01-04, 16:34
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
|
|
mind telling us what worked? 
|
|

10-01-04, 17:17
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,570
|
|
yeah, I'm curious too. I can't seem to engage omniscient mode at the moment, so I'd like a wee bit more feedback.
-PatP
|
|

10-01-04, 17:25
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
|
|
heh
i always say something like "my crystal ball runs on Windows™ ME© and is down at the moment"
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|