substr? How can I retrieve the codes that are only 6 characters

I have this request
 
SELECT 
distinct
SUBSTR(A.STVSBGI_CODE,1,6),
SUBSTR(B.STVSBGI_CODE,1,6),
A.STVSBGI_TYPE_IND,
B.STVSBGI_CODE, 
B.STVSBGI_TYPE_IND
FROM 
stvsbgi A ,
stvsbgi_TEST6C B
WHERE A.STVSBGI_TYPE_IND = 'C'
AND B.STVSBGI_TYPE_IND = 'C'
AND instr(A.STVSBGI_CODE,1,6) =  instr(B.STVSBGI_CODE,1,6)
 
I want to be able to extract ONLY the values (STVSBGI_CODE) where the SUBSTR (A.STVSBGI_CODE, 1, 6).
There are codes in the tables of 4 characters, the query gives me 4-6 characters...
How can I write the query to get the 6-character codes
Thank yoou

Hello

If you want to only include lines in the output, if the code is at least 6 characters?
Add to the WHERE clause:

AND     LENGTH (a.stvsbgi_code)     >= 6

It doesn't matter if you use a. stvsbgi_code and b. stvsbgi_code in this State; the join condition is already excluding the lines where it is less than 6 characters but the other is not.

I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.

Published by: Frank Kulash, November 18, 2011 12:58

Tags: Database

Similar Questions

Maybe you are looking for

  • My iPhone has image problems.

    The button trim is there and it will allow me to crop, but as soon as I press "done" it is said that there is a problem. My iPhone doesn't let me send pictures via text or Facebook messenger unless it's a screen that has been making contortions 10 mi

  • HP 430: On RAM

    I have 2 GB of ram. but my laptop is so slow. I am now deciding to change my ram. who is the highest range to take ram for HP 430?

  • Photosmart 5515: printing of the black bands with letters between them

    When I turned on the printer in a few minutes he printed some old stuff, so I have cancellation print and reset the queue of print. then I turn it on and once again and it automaticly in 30s feel something I don't know what it was on paper 4 black ba

  • 10 Windows recovery media does not work on 3020MT tour

    I have a number of systems with lower upgrade Windows 7 installed by default. So I changed the firmware in the UEFI as shown: I then started the UEFI boot option dvd DVD, and then try again to install the OS, but don't have the option, I also checked

  • HP Deskjet F335 all-in-one: Troubleshooting computer says printer is disabled

    I am trying to print but I get the message of my printer is offline.  I ran the troubleshooting tool and the message that printer has been turned off returned.  The printer is on and I can print the test since the HP Solution Center page