Discussion:
SQL syntax
(too old to reply)
Doug Howell
2013-03-28 16:32:51 UTC
Permalink
I have a SQL syntax question:

SELECT DISTINCT SUBSTRING(PZPPN,1,7)AS "Parent",SUBSTRING(CMDESC,2,24)AS "Description",PZSEQ AS "SeqNum",PZCPN AS "Component",(PZQTY/(10^PSDCC)) AS "Percent"
FROM AS400.S102BAFE.AADAT10.DE120M DE120M, AS400.S102BAFE.AADAT10.DE100M DE100M
WHERE PZPPN LIKE '%000/%' AND PEFOUT='0' AND PZPPN=IZPN AND PSPLNT='100'
ORDER BY Parent,SeqNum

I get the following error:

Msg 402, Level 16, State 1, Line 1
The data types int and numeric are incompatible in the '^' operator.


What am I doing wrong?


Doug
Bob Barrows
2013-03-28 18:57:17 UTC
Permalink
Post by Doug Howell
SELECT DISTINCT SUBSTRING(PZPPN,1,7)AS
"Parent",SUBSTRING(CMDESC,2,24)AS "Description",PZSEQ AS
"SeqNum",PZCPN AS "Component",(PZQTY/(10^PSDCC)) AS "Percent" FROM
AS400.S102BAFE.AADAT10.DE120M DE120M, AS400.S102BAFE.AADAT10.DE100M
DE100M
WHERE PZPPN LIKE '%000/%' AND PEFOUT='0' AND PZPPN=IZPN AND
PSPLNT='100'
ORDER BY Parent,SeqNum
Msg 402, Level 16, State 1, Line 1
The data types int and numeric are incompatible in the '^' operator.
What am I doing wrong?
Perhaps mistaking what the ^ operator does? In T-SQL ^ is. From BOL:

^ (Bitwise Exclusive OR) (Transact-SQL)
Performs a bitwise exclusive OR operation between two integer values.

I suspect you are looking for the POWER function, which:
Returns the value of the specified expression to the specified power. POWER
( float_expression , y )

Continue reading on narkive:
Loading...