I have a little tricky question in Oracle. Right now I have a SQL string which looks like
The codes could look like "40070101". I want both to select my_code, but also the number of 'green numbers' in each 'red number'. So if there exists following codes: "40070101", "400701??", "40070106", then the number of 'green numbers' in each 'red number' is 01+02+03+04+05+06 = 6. I guess I have to make a SELECT-query in my SELECT-query and to find the red and green numbers I can use SUBSTR(my_code, 5, 2) and SUBSTR(my_code, 7, 2). So how will the syntax?
Code:
SELECT my_code FROM TABLE WHERE my_code IS NOT NULL
The codes could look like "40070101". I want both to select my_code, but also the number of 'green numbers' in each 'red number'. So if there exists following codes: "40070101", "400701??", "40070106", then the number of 'green numbers' in each 'red number' is 01+02+03+04+05+06 = 6. I guess I have to make a SELECT-query in my SELECT-query and to find the red and green numbers I can use SUBSTR(my_code, 5, 2) and SUBSTR(my_code, 7, 2). So how will the syntax?