substr help

2012-02-16  Source: Original Site  Category:Oracle  Views:0 

Advertisement

I need to derive last 2 numbers after the '-' from the code column.
example if the code is 76767-99 then I need a query to return only 99. I am using substr and instr functions but not getting what I want. Please help me correct the below query.
code - 76767-99

select NVL (TRIM (SUBSTR (code,
(INSTR (code,
'_'
)
)
+ 1
)
),
'0'
) from temp_table;

Related articles
  • substr help 2012-02-16

    I need to derive last 2 numbers after the '-' from the code column. example if the code is 76767-99 then I need a query to return only 99. I am using substr and instr functions but not getting what I want. Please help me correct the below query. code

  • Oracle substr- help!!!!!!!!! 2012-10-01

    I have the following value: W0002280104 in col1 I need to change it to: 02W on an insert into col3. I assumed that the following would work: insert into col3 substr(col1,2,3)||substr(col1,1,1). But that gives me: 002W, any help is greatly appreciated

  • Oracle Substring help 2012-10-10

    I have a field date field 'x' with values like 1231, 1130, 830, 630, 430, 1030 I need to extract only annual and semi annual date information like month starting 12 and 6. How do I use substring or any other functions??

  • GROUP BY substring help 2013-08-05

    I'm trying to SUM and group data by the first 3 characters of a string(DIC code). However I can't get the same DIC codes to combine into one and total the Qty's. How can I modify the code below to get the results I want? I tried removing data1 from t

  • Simple substring help! 2013-11-21

    Question: Write a program to read in a sentence. Output the sentence and then sort all letters in descending order. Allow users to enter a letter and output the letter with the number of occurrences of that letter, or else indicate that the letter is

  • substring help 2014-03-31

    please help me in developing query to satisfy this... i have table called test and the table data looks like this. col1 123.abc 1.ab 12.cba the query needs to return all rows data after . the result set should return this abc ab cba appreciate your h

  • mySQL CAST SUBSTRING help 2015-02-28

    is there a way which i am able to cast/ convert my substrings into integer? This is what i have been trying to do, apparently, it does not work. SELECT campaignmonth CAST(campaignmonth, substring(campaignmonth,1,1)as Jan) FROM campaign a;

  • Oracle REPLACE / SUBSTR help 2014-10-07

    Please someone could tell me if there is way to replace first part in URL's i.e http://ghf.hq.fde.com:9211, http://ghf.hq.fde.com:92111 with http://efs.hq.def.com . Length of first part may not same always. http://ghf.hq.fde.com:9211/psp/VADEV/EMPLOY

  • C++ Builder 'SubString', 2012-07-08

    I want to get SubString with using this function but C++ Builder 6.0 displays error: "Call to undefined function 'SubString'" Help file says that it's in dstring.h or wstring.h. I have both of them included but anyway bcb displays error. What im doin

  • Help with substring-before function 2012-01-12

    I need help with using the substring-before function. Right now all I am trying to do is get it to work and show it in a label.text. Below is the code I have, but it does not get recognized and errors come up. This is the code I wrote lbl5.text = sub

  • Help with SUBSTR syntax 2012-01-27

    I need help with my statement using the SUBSTR. ( And this is not the MS SQL - but some flavor like it that we use on our AS400) SELECT DISTINCT codstrctn, coacctno, cosrvlcn, losrvlctyp, losrvlcsts, losrvlcnm, losrvlcnml, losrvlc, losrvlcn1, losrvlc

  • Oracle need help with sql - substr function? 2012-03-01

    I apologize for the elementary question - I am still learning. Can someone help me and tell me why my query is not working? I need to pull a few values from Data Warehouse. One of the values needs to be formatted, where the nine characters that are t

  • Problems with Substr().. plz help :( 2012-05-19

    I have an ID number that I am store in a database. Let me use the following demonstration as an example of what is happening. This is an example ID number that is stored in the database: 02080001-SV-01 I select it from the database as $id so for this

  • Help! Replacing occurrences in substring 2012-10-06

    I am new to Java, I'm stuck with this code: public static String[][] numbers = { {"8", "a"}, {"4", "b"}, {"2", "c"}, {"1", "d"} }; public static String swap(String bString) { String result = new String(); for (int i = 0; i<bString.length(); i++) {

  • help with "substr" 2012-12-12

    Would someone help me please? Right now, I have a list of comma-delimited 10-digit numbers, like this for example: 1234567890,1111111111,6666666666,8484848484 and this function locates them perfectly in the context of my scripting: $number = substr($

  • Substring Operations Produce Odd Error - Please Help! 2013-02-24

    I've got an assignment due Monday, and I've gotten the program down to one tiny error, and it's cosmetic at best. However, I'd like to have the assignment done to the letter just in case. In the block below, the program is supposed to force the outpu

  • Oracle substri and instr problem --Please help 2013-02-25

    I would like to get the find tablename starts with 'EXP' using substring and instring . I am using oracle 9i. Please help me out Example : 'Schema.explogtable' I will use table name ' EXP' in one of my procedure as input parameter to procedure If tab

  • trying to use substr to extract data from a string of bytes, help would be great 2013-03-19

    What I am trying to do is implement my own sequence number program. I have a sequence number i.e 0001 and then I try to convert this to a binary string in byte format of 4 bytes: 00 01 00 00 And then I am appending this in the middle of a byte payloa

  • Need help with mock substr function and output 2013-04-15

    Here is a simple substring type function that I wrote in C. char *substr(char arr[], int pos1, int pos2){ char str[100];char *sub; for (int i = 0; i <= (pos2 - pos1); i++){str[i] = arr[i+pos1];} sub = str;printf("Sub: %s\n", sub); // debugging pur

  • MySQL Help in select query using substring function 2013-05-28

    I have to select a substring from a given string..It goes like this The string is like this - 4000-90-4090-100-6090 I want to get the result like 4000-6090 ie the last two parts only with a hyphen in b/w..could anybody out there please help me out wi