We have a table like this:
number branch code
1000 center XXCO
1001 xyz XXER
1002 zyx XXRE
2000 center2 YYCO
2001 xyz YYER
2002 zyx YYRE
All the items that have "CO" in the end of their code are parents to the items that have the same first two symbols in the code.
The task is to get a list of all the branches with their respective parents, like this:
center xyz XXER
center zyx XXRE
center2 xyz YYER
center2 zyx YYRE
I try the following code:
SELECT b.branch, a.branch, a.code
FROM tmp a JOIN tmp b ON
left(a.code,2) = left(b.code,2)
AND a.code NOT LIKE '%CO' AND b.code LIKE '%CO';
But I get an error pointing at the "= left" position in the script.
ORA-00904: "LEFT": недопустимый идентификатор
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 3 Column: 17
What can be the reason for this? Can anybody please help?