I am having a problem with using Mod(%) math in a SQL query with the IMINVLOC and OEORDLIN tables. I want to do a modulus division of OEORDLIN_SQL.qty_ordered by IMINVLOC_SQL.recom_min_ord to check customer order quantities for valid amounts. I have the following SQL Query but it gives me an error.
SELECT dbEORDLIN_SQL.item_no AS "item_no", dbEORDLIN_SQL.qty_ordered AS "qty_ordered", dbo.IMINVLOC_SQL.recom_min_ord AS "recom_min_ord", dbEORDLIN_SQL.qty_ordered % dbo.IMINVLOC_SQL.recom_min_ord AS "calc_qty"
FROM (dbo.IMINVLOC_SQL LEFT OUTER JOIN dbEORDLIN_SQL ON dbo.IMINVLOC_SQL.item_no = dbEORDLIN_SQL.item_no) WHERE dbo.IMINVLOC_SQL.recom_min_ord > 0
ORDER BY dbEORDLIN_SQL.item_no ASC
The error is SQL Server Error #8117 "Operand Data Type Numeric is invalid for Modulo operation".
I have created the same SQL Query in Access and I can run it just fine, but when I try to run the same query checking for calc_qty=0, I receive the same error.
Strangely enough I can create a Crystal Report that does allow me to search for only > 0 calc_qtys but I would prefer to use the above SQL as an event in Event Manager to allow more targetted reporting.
I have visually scanned through the tables and have not seen any data that appears to be corrupted or out of type.
I am running Macola SQL 7.6.1a
Thanks in advance,
pticarlw
SELECT dbEORDLIN_SQL.item_no AS "item_no", dbEORDLIN_SQL.qty_ordered AS "qty_ordered", dbo.IMINVLOC_SQL.recom_min_ord AS "recom_min_ord", dbEORDLIN_SQL.qty_ordered % dbo.IMINVLOC_SQL.recom_min_ord AS "calc_qty"
FROM (dbo.IMINVLOC_SQL LEFT OUTER JOIN dbEORDLIN_SQL ON dbo.IMINVLOC_SQL.item_no = dbEORDLIN_SQL.item_no) WHERE dbo.IMINVLOC_SQL.recom_min_ord > 0
ORDER BY dbEORDLIN_SQL.item_no ASC
The error is SQL Server Error #8117 "Operand Data Type Numeric is invalid for Modulo operation".
I have created the same SQL Query in Access and I can run it just fine, but when I try to run the same query checking for calc_qty=0, I receive the same error.
Strangely enough I can create a Crystal Report that does allow me to search for only > 0 calc_qtys but I would prefer to use the above SQL as an event in Event Manager to allow more targetted reporting.
I have visually scanned through the tables and have not seen any data that appears to be corrupted or out of type.
I am running Macola SQL 7.6.1a
Thanks in advance,
pticarlw