In AS400, how can i perform arithmetic operations (like +, -) on fields.
- For the query
Select id, sum(field1+field2) as Total from table
, getting the following error msg in German "[IBM][System
group by id
i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 – Token & ungültig.
Gültige Token: + – AS<IDENTIFIER>
." English Translation is something
like "[IBM] [System i Access ODBC Driver] [DB2 for i5/OS] SQL0104 –
Token<END Instruction>
invalid. Valid tokens: CL AS IN LOG OUT DATA
<identifier>
." - For the query
Select count(*) from (select distinct field1 from table where field2="abc"
, getting the following error msg "[IBM][System i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 – Token<ENDE DER ANWEISUNG>
ungültig. Gültige Token: AS CL IN LOG OUT DATA<IDENTIFIER>
." - For a query with sub-query got the following error msg
"[IBM][System i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 – Token & ungültig. Gültige Token:<
>
=<>
<=
!<
!>
!=
>=
¬<
¬>
¬=
IN NOT."
Could someone please tell me what's wrong with my sql queries.
Best Answer
TABLE
is a reserved word. SQL Reference: Reserved schema names and reserved words.SQL Reference: Identifiers
The queries could be re-written as:
UPDATE
DB/2 for i does not support your method of numeric to character conversion or the type of character comparison used in your LIKE query.
The query can be re-written as:
You may need to use
DEC
instead ofINT
depending upon the definition of fieldsds
.SQL Reference: -
INT
-DEC
-BETWEEN