Match the last 2 characters of field of 1 to 2 characters of another field

Hi, I was looking for assistance with regard to get output when the last 2 characters of 1 on the ground of the last 2 characters of another field of a particular job, i.e. repair or the new job. Here's an example of my 2 tables and insert queries.

[code]

CREATE TABLE 'SITES '.

(

'CODE' VARCHAR2 (7 CHAR),

VARCHAR2 (27 CHAR) "NAME."

'SITE_NAME' VARCHAR2 (32 CHAR)

)

Insert in SITES (CODE, NAME, SITE_NAME) values ('CAFC', 'Central', 'Birmingham');

Insert in SITES (CODE, NAME, SITE_NAME) values ('MRCE', 'Central','Manchester ");

Insert in SITES (CODE, NAME, SITE_NAME) values ('LVCE', 'Central', 'Liverpool');

Insert in SITES (CODE, NAME, SITE_NAME) values ("WSCE", 'Central',' West of Central Scotland ");

CREATE TABLE 'JOBS '.

(

VARCHAR2 (20 BYTE) "JOB_REF."

'JOB_TYPE' VARCHAR2 (20 BYTE)

)

Insert into JOBS (JOB_REF, JOB_TYPE) values ('FFR53CM', 'Repair');

[/ code]

So I would take the first 2 characters 'CM' of the Sites Table and at last the match 2 characters of the job Table if the Type of job is the repair and then display the value of the Site name. The reason why I need to filter on the Type of employment is because when a new job is connected so I need to use the first 2 characters rather than the last 2, but I thought I would break it down in order to get the work of part 1.

Unfortunately I do not know how I can display it, also do not know whether to use a case statement, but still don't know how to write it.

If someone could please advise, really appreciate it.

Thanks in advance.

976439 wrote:

How I guarantee that it is only for the repair of Type of work?

You know the SQL language don't you?

What is the problem with everything by adding:

where job_type = 'repair '.

to the query.

Blimey! I don't think I would be hand-holding today.

Tags: Database

Similar Questions

  • replace only the last 3 characters within a string

    Hi all
    I have the string "abcdef_01". How can I replace the last 3 characters with "000"? in this string, for example "_01" should be replaced by '000'. Any way to do it, without the concatenation of the original string with the last 3 characters replaced by "000"?
    Thank you

    Edited by: Roger22 the 18.10.2011 09:29

    Yes, you can...

    SELECT rpad(substr('abcdef_01',1,length('abcdef_01')-3),length('abcdef_01'),chr(dbms_random.value(32,64))
                                                                             || chr(dbms_random.value(32,64))
                                                                             || chr(dbms_random.value(32,64)))
    FROM dual;
    

    RPAD/lpad may use a third parameter that is longer than 1 character and - if the duration of param 1 + length of parameter 3 is longer that parameter 2 - truncates the result to fit the length of parameter 2.

    HTH

  • How can I get the last 3 characters of the record

    Hello

    This statement [cdoe] select substr (password, 1, 3) to admin; Gets first 3 characters that I want to read the last 3 characters

    Best regards
    SQL> select substr('Raakh',-3) from dual;
    
    SUB
    ---
    akh
    
    1 row selected.
    

    Kind regards
    Rob.

  • How to extract the last 5 characters of the column CLOB001?

    Hi all

    I've set up an external WS in the APEX and now I want to create a report with the following query:

    Select dbms_lob. Substr (CLOB001, 5, -5) 'Test '.

    of APEX_collections

    where collection_name = "P422_CHECKVAT_RESULTS";

    What I want to do is to retrireve the last 5 characters in the CLOB, has anyone any ideea how I can do this?

    Kind regards
    Ana-Maria
    SELECT dbms_lob.Substr(CLOB001,dbms_lob.getlength(CLOB001),dbms_lob.getlength(CLOB001)-5 ) test
      FROM HTMLDB_COLLECTIONS
     WHERE COLLECTION_NAME = 
    {code}
    
    Hope this helps...
    
    Tyson                                                                                                                                                                                                                                                                                                                                                                                                                            
    
  • Hi all, please help me to retrieve the last record value in field

    Hi all

    Shape the table below, I want to retrieve the latest data from column 4 disks in a new field that will be my field of view as shown in the end of the table by means of BI publisher, please help to achieve this goal.

    Column1 2 3 4 5 6

    May 1, 1067205671982868062
    May 1, 10034925706902868065
    15 May 102500005456901634220
    15 June 106000000-543101657501

    New field -54310

    Thank you and best regards,

    Prasad.

    something like

    for each: ByWhichLoop [last()]

    end foreach

  • How to get the last 50 characters in a string

    Hi, I need to get 50 last characters in a piece of 25 characters each in two columns if the column notes less than 50 characters ex: 43 then I need to last 25 one column and left (18 characters) in the second column.     I tried using substr and the first column of length functions fine, but the second column has a problem: select substr ("ABCDEF GHIJ', length('ABCDEF GHIJ')-25, 25) of double; Thanks, Kiran

    Hello

    what I understand: if I call 'x' the length of the string:

    IF x > is 50 THEN result1 is 25 tanks, result2 = 25 characters

    IF 25< x=""><  50 ="" then="" result1="25" chars,="" result2="(" 25="" -="" x="" )="">

    IF x<= 25 ="" then="" result1="x" chars,="" result2="">

    Note that SUBSTR (x, n) selects the n last characters:

    SELECT SUBSTR ("ABCDEFGH",-3) FROM dual-> ANUS

    For example AS

    (SELECT "AAAAABBBBBCCCCCDDDDD" double str

    UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG' FROM dual

    UNION ALL SELECT 'this_is_exactly_25__chars' FROM dual

    UNION ALL SELECT 'This___is___exactly___fifty___characters' FROM dual

    UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK' FROM dual

    )

    SELECT str

    LENGTH WHEN CARTER (str)<>

    THEN str

    WHEN LENGTH (str)<>

    THEN SUBSTR (str, 1, 25)

    Of OTHER SUBSTR (str, LENGTH (str) - 49: 25)

    END performance(1)

    , LENGTH WHEN CARTER (str) > = 50

    THEN SUBSTR (str,-25)

    WHEN LENGTH (str) > 25

    THEN SUBSTR (str, 25 - LENGTH (str))

    ANOTHER NULL

    End result2

    SAMPLE

    ;

    STR                                                    RESULT1                   RESULT2

    ------------------------------------------------------ ------------------------- -------------------------

    AAAAABBBBBCCCCCDDDDD AAAAABBBBBCCCCCDDDDD

    AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG AAAAABBBBBCCCCCDDDDDEEEEE FFFFFGGGGG

    this_is_exactly_25__chars this_is_exactly_25__chars

    This___is___exactly___fifty___characters This___is___exactly_ ___fifty___characters

    AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK ABBBBBCCCCCDDDDDEEEEEFFFF FGGGGGHHHHHIIIIIJJJJJKKKK

    Best regards

    Bruno Vroman.

  • update query - remove the last 3 characters of field3 of all records

    I have a table full of details of the vehicle. A field contains a part number. for example.
    DR4050 (K)

    I need to remove the (K) of each part in the table number

    Can someone explain how to do this?

    Thank you very much. I took your advice and check the string of MySQL functions. This is the statement that did the trick for me:

    Update transmission_copy
    Set outer_cv_joint_left_side = replace (outer_cv_joint_left_side, "(K)", "");

  • With the help of characters in another project to animate cc?

    I have a project with a symbol and I want to use that symbol in another project. I tried to use adobe cc library by dragging the symbol in the library of adobe cc library, and it does not work. I tried to look for how to save symbols flash in the form of files, and that no longer works. Help!

    Thank you

    You can't redraw anything.  Simply copy and paste into the new file.

  • Find the last characters with grep

    I'm lousy with grep and didn't find the solution with google, we will so ask here (help me, please...)

    I need to find the last 7 characters in a paragraph and assign a character style "not break". I know that all the rest, but what is the string to find the last 7 characters (white space included, numbers and letters).

    Thanks in advance.

    try searching. {7} $

  • How to find the last update date, time and user of the file field peoplecode

    How to find the last updated date time fields of peoplecode records?

    Thank you.

    We can check the update date-time using the following query

    SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".

  • How to use GREP expression to group the last two words of a paragraph?

    Hi guys, I'm dealing with a document that is riddled with the orphan and want to use GREP to get rid of them all.

    I found this thread talking about how to group all the last 10 characters. But in my language, you can have up to 4 words together (almost a third of the sentence!) and still not break the limit of 10 characters. So if I use this expression, a sentence cut in half way, which make the whole paragraph looks horrible. I also tried the (\s\w+)? $ expression, but he left a few intact orphans (No. very random, model at all).

    So is there any other expression that can make the last 2 words of any paragraph together like glue stick?

    (\H+?\h ?) {2} $

    (^/)

  • Find the folder with the timestamp of the last

    Hello

    I have a table that has four fields.


    CREATE TABLE MATCH_L
    (
    SUBSCRIPTION_INFO VARCHAR2 (512 BYTE),
    SUBSCRIBERID NUMBER NOT NULL,
    VARCHAR2 (12-BYTE) USERID NOT NULL,.
    TIME_LAST_USED TIMESTAMP (6) NOT NULL
    )
    TABLESPACE TEST1
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE)
    64K INITIALS
    ACCORDING TO 1 M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    DEFAULT USER_TABLES
    )
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;



    For each couple of records like below

    FSB0004609 42 192902070016 2012-05-03 10:30:33, 011000
    FSB0004609 42 192902070016 2012-04-19 14:30:33, 627000
    FSB0004609 42 192902070016 2012-04-03 16:28:16, 019000
    FSB0004609 42 192902070016 2012-03-21 17:11:04, 398000
    FSB0004609 42 192902070016 2012-04-30 09:12:40, 366000


    SUBSCRIPTION_INFO, SUBSCRIBERID, USERID are the same and they differ just in the timestamp.

    So I want to get my hands on one of these "all the two files" that are having the last TIME_LAST_USED.

    I hope you understood what I want (in another interpretation, I want to have a USER SUBSCRIPTION_INFO name, SUBSCRIBERID, distinct but not not using separate in the query)

    Please let me know if my explanation is not enogh.

    Concerning

    / Louis

    Published by: Louis March 19, 2013 15:01

    Simply use GROUP BY:

    SELECT  SUBSCRIPTION_INFO,
            SUBSCRIBERID,
            USERID,
            MAX(TIME_LAST_USED) TIME_LAST_USED
      FROM  MATCH_L
      GROUP BY SUBSCRIPTION_INFO,
               SUBSCRIBERID,
               USERID
    /
    

    SY.

  • GREP expression for the last line, followed by the column break

    For all of you who read this, thank you for taking the time to help. I'm a noob to JavaScript and GREP expressions, so thank you for all your time and help with this.

    I wrote a JavaScript script to help my company format some of our work more quickly. We have pre-made models with character Styles all implemented (body, header, BodyItalic) etc.

    My script works almost perfectly to identify patterns and apply the correct character style.

    However, my expressions do not work perfectly and last line of text in the text box (linked), which has a column break, do not get to the format.

    This last line is always different depending on the document. So I can't put in the constants. They are always variable.

    My current GREP expression is. + ~ M which, theoretically, should find any character who repeated one or more times and is followed by a column break. The problem is, he finds that the last two characters on the line which are followed by a column break.

    for example

    Tribute would be tribeTE

    Eulogy would be EuloGY

    etc etc.

    As you can see, they are not always the same words and could even be a short sentence so I can't just look like some words.

    I am trying to establish why the GREP expression does not. Maybe I use GREP evil symbols? I don't know, so any help would be appreciated.

    Thank you in advance.

    Scorpio

    This column break thing seems bugy. I have no idea why only the last two characters are found. If I try to find an entire word with \w+, which does not work. I get results as weird if I try to \b\w+~M. the good news, is that InDesign is no crash, here.

    However: There is no GREP to search a specific line, so I'm looking for a columnbreak and then for the line which belongs to the aware found:

    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "~M"; 
    var found = app.activeDocument.findGrep();

    if (found.length > 0) {
    for ( var i = 0; i < found.length; i++ ) {
      var curFound = found[i];
      var curLine = curFound.lines[0]; 
      curLine.fillColor = app.activeDocument.swatches[4];
    }
    }

  • Check the last instance of a textfield is not null

    I have a repeating subform that includes a textfield for the user to enter his name. When the user clicks a button e-mail customized to send the form, I first want to check if the last instance of this field is filled (non-null). I don't care about previous instances only the last instance. Custom e-mail button is pushed down below each instance of the subform is always just below the last instance of the repeating subform. Is it possible to refer to the last instance of a field in the subform when I do not know how many instances are created?

    Thank you

    Hi DKinsley,

    I think that the code and the following steps will solve your problem.

    (1) in order to know the last instance, you must find the number of available instances. This can be achieved with the following code.

    var totalRowInstances = xfa.resolveNode ("form. Name.txtName").instanceManager.count;

    (2) to access the last value of the index,

    lastIndex var = totalRowInstances-1;

    [Since the index always starts with 0]

    var lastIndexNameCheck = xfa.resolveNode ("form. ("Name [" + lastIndex + '] '). txtName.rawValue;

    If (lastIndexNameCheck! = null)
    {
    do something
    }
    on the other
    {
    do something
    }

    Please Note: here, form - refers to the root node, name - refers to the subform, txtName - made reference in the name of a text field.

    Please let me know if this helped.

    Thank you
    VJ

  • last 3 characters of a string

    How to get the last 3 characters of a string occuring after a character / alphabet  without using REGEXP_SUBSTR ? 
    
    Ex: 10000A001 is the string.
    
    Note: -  I want to use it in Oracle reports 6i, therefore i cannot use the statement REGEXP_SUBSTR 
    
    Sanjay

    Hello

    substr('10000A001',-3)
    

Maybe you are looking for