Need help with patterns of comparison (analytical SQL?)

Hello Forum users,.

I have a strange problem on my hands that I cannot think of an effective way to code in Oracle SQL...

(1) background

Two tables:

MEASURES
IDENTIFICATION NUMBER
M1 NUMBER
NUMBER M2
M3 NUMBER
M4 NUMBER

INTERESTING_VALUES
IDENTIFICATION NUMBER
M1 NUMBER
NUMBER M2
M3 NUMBER
M4 NUMBER

(2) OUTPUT NEEDED

For each line of 'MEASURES', count the number of matches in 'INTERESTING_VALUES' (all lines). Please note that the games could not be in the same column, for example for a given row MEASURES M1 may correspond to INTERESTING_VALUES M3.

I need to count the 2,3 and 4 matches and provide the values of the County stay.

I'm not interested in partial matching (for example "superior to" or "less than"), numbers only need to match exactly.

(You can use the features up to 11g).

Thank you for your help.

Well Yes, here you go...

SQL> select * from measurement;

        ID         M1         M2         M3         M4
---------- ---------- ---------- ---------- ----------
         1         30         40        110        120
         2         12         24        175        192
         3         22         35        147        181

SQL> select * from interesting;

        ID         M1         M2         M3         M4
---------- ---------- ---------- ---------- ----------
         1         16        171         30        110
         2         40        171         30        110
         5        181        147         35         22
         4        175         12        192         24
         3        175         86        192         24

SQL>  SELECT id,
  2    SUM(
  3    CASE
  4      WHEN LEN=1
  5      THEN 1
  6      ELSE 0
  7    END) repeat2,
  8    SUM(
  9    CASE
 10      WHEN LEN=2
 11      THEN 1
 12      ELSE 0
 13    END) repeat3,
 14    SUM(
 15    CASE
 16      WHEN LEN=3
 17      THEN 1
 18      ELSE 0
 19    END) repeat4
 20     FROM
 21    (SELECT id,
 22      spath   ,
 23      (LENGTH(spath)-LENGTH(REPLACE(LOWER(spath),',') ))/ LENGTH(',') LEN
 24       FROM
 25      (SELECT t.* ,
 26        ltrim(sys_connect_by_path(cvalue,','),',') spath
 27         FROM
 28        (SELECT p.*,
 29          row_number() over (partition BY id, id1 order by cvalue) rnum
 30           FROM
 31          (SELECT m.id,
 32            m.m1      ,
 33            m.m2      ,
 34            m.m3      ,
 35            m.m4      ,
 36            (SELECT COUNT(*)
 37               FROM interesting q
 38              WHERE q.id=I.id
 39            AND (q.m1   = column_value
 40            OR q.m2     =column_value
 41            OR q.m3     =column_value
 42            OR m4       =column_value)
 43            ) cnt              ,
 44            column_value cvalue,
 45            i.id id1           ,
 46            i.m1 m11           ,
 47            i.m2 m21           ,
 48            i.m3 m31           ,
 49            i.m4 m41
 50             FROM measurement m                   ,
 51            TABLE(sys.odcinumberlist(m1,m2,m3,m4)),
 52            interesting I
 53         ORDER BY id,
 54            id1     ,
 55            cvalue
 56          ) p
 57          WHERE cnt=1
 58        ) t
 59        WHERE level        >1
 60        CONNECT BY prior id=id
 61      AND prior id1        =id1
 62      AND prior rnum      <=rnum-1
 63        --start with rnum=1
 64     ORDER BY id,
 65        id1     ,
 66        cvalue
 67      )
 68   ORDER BY 1,2
 69    )
 70  GROUP BY id
 71  ORDER BY 1;

        ID    REPEAT2    REPEAT3    REPEAT4
---------- ---------- ---------- ----------
         1          4          1          0
         2          9          5          1
         3          6          4          1

I write the code without number so that it is easier for you to copy formatting code...

select id,sum(case when len=1 then 1 else 0 end) repeat2,sum(case when len=2 then 1 else 0 end) repeat3,sum(case when len=3 then 1 else 0 end) repeat4 from
(select id,spath,(LENGTH(spath)-LENGTH(REPLACE(LOWER(spath),',') ))/ LENGTH(',') len from
(select t.*
,ltrim(sys_connect_by_path(cvalue,','),',') spath
from (select p.*,row_number() over (partition by id, id1 order by cvalue) rnum from (SELECT m.id,
    m.m1      ,
    m.m2      ,
    m.m3      ,
    m.m4      ,
    (SELECT COUNT(*)
       FROM interesting q
      WHERE q.id=I.id
    AND (q.m1    = column_value
    OR q.m2     =column_value
    OR q.m3     =column_value
    OR m4       =column_value)
    ) cnt              ,
    column_value cvalue,
    i.id id1           ,
    i.m1 m11           ,
    i.m2 m21           ,
    i.m3 m31           ,
    i.m4 m41
    FROM measurement m                     ,
    TABLE(sys.odcinumberlist(m1,m2,m3,m4)),
    interesting I
  order by id,id1,cvalue
  ) p where cnt=1
) t where level>1
connect by prior id=id and prior id1=id1 and prior rnum<=rnum-1
order by id,id1,cvalue) order by 1,2) group by id order by 1

Ravi Kumar

Published by: ravikumar.sv on 15 Sep 2009 15:54

Tags: Database

Similar Questions

  • Need help with the condition join in SQL

    Hi all -

    I need to ask for help with this query:

    Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));

    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ("Column3", 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('column4', 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ("column1", "table2", 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', "Column3", 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column4', 'varchar2')
    Commit;

    Create table all_cons_columns_test (varchar2 (30) from table_name, column_name varchar2 (30), constraint_name varchar2 (30))

    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "primary")
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "secondary")
    Commit;

    This is my query and the current result:

    Select u.table_name, u.column_name, c.constraint_name
    Of user_tab_col_test u
    Outer join all_cons_columns_test c left
    On (u.table_name = c.table_name
    AND U.COLUMN_NAME = C.COLUMN_NAME
    AND C.CONSTRAINT_NAME IN ('main'))
    order of U.table_name, U.COLUMN_NAME;

    TABLE_NAME COLUMN_NAME, CONSTRAINT_NAME
    ------------------ --------------------- ----------------------------
    Table1 primary Column1
    Table1 Column2
    Table 1 Column3
    Table2 Column1
    Table2 Column2


    Three questions:
    (1) I don't want to return results where table_name = "table1". I can't get this to work.
    (2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.
    (3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?

    Any advice/suggestions are appreciated-
    John

    Published by: user703358 on January 11, 2013 20:57

    Published by: user703358 on January 11, 2013 21:48

    Hi, John,.

    user703358 wrote:
    Hi all -

    I need to ask for help with this query:

    Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));

    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')...

    Thanks for posting the CREATE TABLE and INSERT.
    It is more useful if you post the code that can be run without modification. You did not semicolons after INSERTION instructions.

    Three questions:
    (1) I don't want to return results where table_name = "table1". I can't get this to work.

    What have you tried? Post your best attempt.
    Here's one way:

    SELECT    u.table_name
    ,        u.column_name
    ,        c.constraint_name
    FROM             user_tab_col_test      u
    LEFT OUTER JOIN  all_cons_columns_test  c
                            ON    u.table_name     = c.table_name
                   AND   u.column_name     = c.column_name
                   AND   c.constraint_name IN ('primary')
    WHERE       u.table_name     = 'table1'          --  *****  NEW  *****
    ORDER BY  u.table_name
    ,            u.column_name
    ;
    

    You would not put this condition in the clause; who controls what is considered as a match between the tables, and "u LEFT OUTER JOIN c" means show all lines of u, even if they do not have a match in the c.

    (2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.

    Basically, this application is very well.
    It displays all the columns of user_tab_col_test; missing data_type. Just add u.data_type to the SELECT clause, or change the SELECT clause

    SELECT    u.*
    ,         c.constraint_name
    

    (3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?

    Do you mean "" * add * one-third * column * to all_cons_columns_test '? "
    It depends on what results you want. Post new CREATE TABLE and INSERT and instructions the results you want new data.
    Most likely, the basic structure of what you've written will remain exactly the same.

  • Need help with an exercise in PL/SQL? Exceptions.

    Hello!

    Im very new to pl/sql. So I need the syntax, im use the HR schema. Here is the exercise.

    Create a package (EXC_PKG) that contains the type of statement that one Exception SALARY_TO_HIGH exception.

    Create another package (SETSAL_PKG) with a procedure (SET_NEW_SAL) that allows the update of wages on the Employee table
    an employee designated.

    The program will check that the wage does not exceed 6000.

    If the salary is higher than 6000 then the application should use the exception in the EXC_PKG package

    and displays the message: wages (< new >) will not exceed 6000.

    Thx for the help!

    Love me

    Hello

    A package includes 2 parts:
    -a package specification
    -a package body

    Try the following, your SQL * more prompt:

    MHO%xe> create or replace package setsal_pkg
      2  as
      3  procedure set_new_sal;
      4  end setsal_pkg;
      5  /
    
    Package is aangemaakt.
    
    Verstreken: 00:00:02.95
    MHO%xe>  create or replace package body setsal_pkg
      2  as
      3  procedure set_new_sal
      4  is
      5  begin
      6   dbms_output.put_line('Hello World!');
      7  end set_new_sal;
      8  end setsal_pkg;
      9  /
    
    Package-body is aangemaakt.
    
    Verstreken: 00:00:00.46
    MHO%xe> set serverout on
    MHO%xe> exec setsal_pkg.set_new_sal
    Hello World!
    
    PL/SQL-procedure is geslaagd.
    

    And keep on OTN visit and bookmark and read the docs whenever you want, it is all documented stuff:
    http://Tahiti.Oracle.com
    http://asktom.Oracle.com

  • Need help with the compilation of PL/SQL procedure

    Hi people,

    Can someone help me with the following problem?

    Version: 10g Rel 2

    I create the following proc

    CREATE OR REPLACE PROCEDURE SYS. "P_SEND_MAIL"(p_message VARCHAR2).
    is
    Start
    UTL_MAIL. SEND ('[email protected]',
    message = > 'Oracle alert. "
    subject = > p_message);
    end;
    */*

    The above proc compile successfully

    Then I create a second proc that references the above proc

    CREATE OR REPLACE PROCEDURE SYSMAN. LOG_CRITICAL_ALERTS (gravity IN MGMT_NOTIFY_SEVERITY)
    IS
    BEGIN
    -Connect all the critical severities
    IF severity.severity_code in (MGMT_GLOBAL. G_SEVERITY_CRITICAL, MGMT_GLOBAL. G_SEVERITY_CRITICAL)
    THEN
    BEGIN
    SYSMAN.p_send_mail (Severity.message);
    EXCEPTION
    WHILE OTHERS
    THEN
    -If there is that no problem, then get the notification retried
    RAISE_APPLICATION_ERROR (-20000, "Please try again");
    END;
    COMMIT;
    END IF;
    END LOG_CRITICAL_ALERTS;
    */*

    I get the following compilation error

    SYSMAN PROCEDURE. LOG_CRITICAL_ALERTS
    Online: 8
    PLS-00201: identifier ' SYSMAN. P_SEND_MAIL' must be declared

    Thanks in advance

    rogers42

    One of the basic directions using Oracle, we should NOT, do not create your own procedures user SYS (or tables also). SYS is the datadictionary. That the datadictionary is changed automatically when importing, it is never exported: provided non-Oracle of objects are ignored.
    System: essentially the same question.

    Why you have this 'problem '.
    Just because you don't read the documentation and do not want to check for errors in the online documentation.

    Would you do that, you would have known
    SYSMAN would need to execute privilege
    You have put in place a public synonym.

    --------------
    Sybrand Bakker
    Senior Oracle DBA

  • need help with the place where small sql query

    types of numbers names {}

    ID | name | ID | Phone | which | type of | ID | type |

    | 1. Jenny | 1. 867-5309 | 1. 3 | | 1. Home |
    | 4: Tom | 4: 555-1212. 3. 1 | | 4: cell |
    | 3. Smith | 3. 364-4311 | 3. 2 | | 3. work |
    | 4. Amy | 4. 936-2828 | 4. 3 | | 4. Fax |
    | 5. 525-8722 | 3. NULL | -----------
    ----------------------------

    I'm currently out put like this:

    Type name phone

    | Smith | Home | 555-1212 |
    | Smith | cell | 364-4311 |
    | Smith | NULL | 525-8722 |

    is it possible to get the time of the tree 'smith' in the name column, which confuses me a lot
    {Please can someone give idea how to solve this problem}

    Published by: user4463478 on May 20, 2009 17:38

    Edited by: user4463478 May 21, 2009 11:51

    Edited by: user4463478 May 21, 2009 11:52
    select n.name,t.type,s.phone
    from names n,numbers s,types t
    where n.id=s.who and
    s.type=t.id(+)---right outer join
    and name ='&name'
     
    

    Here go us

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Need help with SQL/PL/SQL for Dates

    Hi Experts - need help with a SQL query.

    I need to insert some date fields in a table called CALENDAR_PERIOD.

    Current data in CALENDAR_PERIOD table with their data types:

    STARTPERIOD (DATE) YEAR (NUMBER) PERIOD_LABEL (Varchar2 255)

    02/11/2014 2014 2014/02/11 SUN

    03/11/2014 2014 14/03/11 MON

    04/11/2014 2014 11/04/14 MAR

    I have to increment above values up to the year 2025. I don't know how to write SQL and increment of these values.

    Ex: My next value should insert: 05/11/2015 2014 11/05/14 WED like that I need to insert data until 12 31, 2025.

    Can you please help me with PL/SQL block?

    Really appreciate your help!

    DB version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Thank you
    Sandy

    Hello Sandy,

    Maybe something like

    INSERT INTO calendar_period (startperiod, year, period_label)

    SELECT DATE '' 2014-11-04 + LEVEL

    , TO_NUMBER (TO_CHAR (DATE '' 2014-11-04 + LEVEL, "YYYY"))

    , TO_CHAR (DATE '' 2014-11-04 + LEVEL, "MM/DD/YY DY")

    OF the double

    CONNECT BY LEVEL<= date="" '2025-12-314="" -="" date="">

    ;

    ((mais je ne comprends pas pourquoi nous créons une telle table "année" et "period_label" peuvent être calculé à partir de startperiod))

    Best regards

    Bruno Vroman.

  • Need help with PL/SQL query complex

    I need help with a query that need access to data from 3 tables. That's what I did

    I created 3 tables

    CREATE TABLE post_table
    (
    post_id varchar (20),
    datepost DATE,
    KEY (post_id) elementary SCHOOL
    ) ;

    CREATE TABLE topic
    (
    TOPIC_ID varchar (20),
    name varchar (20),
    PRIMARY KEY (topic_id)
    );

    CREATE TABLE blogpost_table
    (
    TOPIC_ID varchar (20),
    post_id varchar (20),
    PRIMARY KEY (topic_id, post_id);
    FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
    FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
    );


    Now, I inserted a few values in these tables as

    INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))

    INSERT INTO VALUES subject ("t1", "baseball");
    INSERT INTO category VALUES ('t2', 'football');

    INSERT INTO blogpost_table VALUES ("t1", "p1");
    INSERT INTO blogpost_table VALUES ('t1', 'p3');
    INSERT INTO blogpost_table VALUES ("t1", "p4");
    INSERT INTO blogpost_table VALUES ('t1', 'p5');
    INSERT INTO blogpost_table VALUES ('t2', 'p2');
    INSERT INTO blogpost_table VALUES ('t2', 'p6');
    INSERT INTO blogpost_table VALUES ("t2", "p7");


    I'm launching SQL queries on the table in this topic.

    I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.

    Can someone please help me to write this query?

    Thank you

    Published by: user11994430 on October 9, 2009 07:24

    Thanks for the test of the configuration!

    SQL>SELECT   t.NAME, COUNT(*)
      2      FROM topic t, blogpost_table b, post_table p
      3     WHERE b.topic_id = t.topic_id
      4       AND p.post_id = b.post_id
      5       AND p.datepost >= DATE '2009-07-01'
      6       AND p.datepost < DATE '2009-08-01'
      7  GROUP BY t.NAME
      8  ORDER BY COUNT(*) desc;
    
    NAME                   COUNT(*)
    -------------------- ----------
    baseball                      2
    soccer                        2
    

    HTH, Urs

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Urgent need help with String Manipulation

    Hello;
    I really need help with strings.

    Let's say I have these channels:
    \\ABC\DEF\GHI\xyz\xyz\xyz\xyz

    \\ABC\DEF\GHI\xyz\

    \\ABC\DEF\GHI\xyz\xyz\xyz\

    \\ABC\DEF\GHI

    \\ABC\DEF\GHI\

    ABC/DEF/GHI/xyz/xyz/xyz/xyz

    ABC/DEF/GHI/xyz /.

    ABC/DEF/GHI/xyz/xyz/xyz /.

    ABC/DEF/GHI

    ABC/DEF/GHI.

    I need to convert them using a SQL statement for:
    \\ABC\DEF\GHI\xyz\ or //ABC/DEF/GHI/xyz/ according to the original management / or \. Please note that the "xyz" may be repeated zero or more times. I just need one end with a trailing / or -if she had one first.

    I'm on Oracle 11.1.6 SE. I have a bunch of attempts with instr, substr and replace, but I think that regexp_replace could be better.
    Any help would be GREAT! I have a whole team waiting on me.

    Hello.

    Here is a way.

    -----------------------------------------------------------------------
    with sample_table as
    (
         select '\\ABC\DEF\GHI\xyz\xyz\xyz\xyz' str from dual union all
         select '\\ABC\DEF\GHI\xyz\' from dual union all
         select '\\ABC\DEF\GHI\xyz\xyz\xyz\' from dual union all
         select '\\ABC\DEF\GHI' from dual union all
         select '\\ABC\DEF\GHI\' from dual union all
         select '//ABC/DEF/GHI/xyz/xyz/xyz/xyz' from dual union all
         select '//ABC/DEF/GHI/xyz/' from dual union all
         select '//ABC/DEF/GHI/xyz/xyz/xyz/' from dual union all
         select '//ABC/DEF/GHI' from dual union all
         select '//ABC/DEF/GHI/' from dual
    )
    select str,
         regexp_replace(str,'(xyz([/\])*)+$','\1') new_str
    from  sample_table;
    
    STR                      NEW_STR
    ------------------------------ ------------------------------
    \\ABC\DEF\GHI\xyz\xyz\xyz\xyz  \\ABC\DEF\GHI\xyz
    \\ABC\DEF\GHI\xyz\            \\ABC\DEF\GHI\xyz\
    \\ABC\DEF\GHI\xyz\xyz\xyz\     \\ABC\DEF\GHI\xyz\
    \\ABC\DEF\GHI                 \\ABC\DEF\GHI
    \\ABC\DEF\GHI\                 \\ABC\DEF\GHI\
    //ABC/DEF/GHI/xyz/xyz/xyz/xyz  //ABC/DEF/GHI/xyz
    //ABC/DEF/GHI/xyz/            //ABC/DEF/GHI/xyz/
    //ABC/DEF/GHI/xyz/xyz/xyz/     //ABC/DEF/GHI/xyz/
    //ABC/DEF/GHI                 //ABC/DEF/GHI
    //ABC/DEF/GHI/                 //ABC/DEF/GHI/
    

    Kind regards.

  • I'm not sure that photoshop to buy, I need help with watermark or copyright law

    I'm not sure that photoshop to buy, I need help with watermark or copyright law

    http://www.Adobe.com/products/Photoshop/buying-guide-version-comparison.html

  • I'm suddenly needing help with my browser Firefox (6.0.2)

    Hello
    I'm suddenly needing help with my browser Firefox (6.0.2)

    (OS: I use Windows XP).

    When I open the browser, I don't see is a totally white screen of white, with all the toolbars at the top.

    I know that my physical connections are very good: I have tested the modem, turned the pc market etc and I can also receive/send emails.

    This problem started today, September 8, 2011 and has never happened before.

    Is it a coincidence that Firefox itself to day before I disconnected yesterday evening? Could this be something to do with this particular new update?

    I also noticed that just before I "opened" Firefox, I now get a small box indicating:

    [JAVASCRIPT APPLICATION]
    Handl exc in Ev: TypeError: this oRoot.enable is not a function

    This never appeared before - I hope that it offers a clue has what is wrong.

    The browser not be stuck in Mode safe, said by the way.

    Of course, I can't find solutions to the problem on the internet, I don't physically see all Web sites!
    (A friend sends this request in my name from their pc)

    Any light you can throw on this problem of confusion would be much appreciated. I'd rather not have to uninstall and reinstall Firefox if possible.

    If the only option is to uninstall Firefox and reinstall from your site, I'm also in trouble (I can not see the internet or download).
    In this case, would you be able to send the .exe file as an attachment to my e-mail address? In the affirmative, please let me know and I'll give you more details.

    Thanks in advance.

    One possible cause is security software (firewall) that blocks or limits Firefox or plugin-container process without informing you, possibly after the detection of changes (update) for the Firefox program.

    Delete all rules for Firefox in the list of permissions in the firewall and leave your firewall again ask permission to get full unlimited access to the internet for Firefox and the plugin-container and the update process.

    See:

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Need help with installation on Photosmart C7280 all-in-one

    I had my printer is installed and has been using the printer for 3 wireless laptops in my house.  Now, I can't even find my backup drive, so I have need help with downloading the software to use my printer and also get to use wireless.   I don't know what happened, but the fax for this printer is listed, but not the printer itself.   Help, please!

    Click here to download the software for your printer:

    http://h10025.www1.HP.com/ewfrf/wc/softwareCategory?product=3204785 & LC = on & CC = US & DLC = in & lang = to & CC = US

    has chosen the appropriate operating system that corresponds to your computer and download the full software features.

  • HP laptop: need help with internet and search for things

    whenever I'm on chrome internet explore google ect and go to tab it is says unknown error or no internet connection or anything and just takes me chrome ect. I need help with this im involved in a byod class and my computer won't let me on what whatever usually it just starts out black and white and the seeds I my search request

    Yes it's a Windows 10 and it arrived already installed I'll take the other info now

  • Need help with the installation of an adapter of Palit GeForce 9500GT Super chart - 512 MB in a M2N68 (narrated

    Need help with the installation of an adapter of graphics Super Palit GeForce 9500GT - 512 MB - DDR2 SDRAM in a M2N68 motherboard (narra6). Should I disable the onboard graphics in the bios? When the card is installed, no VGA work outs and the PC does not start. Checked and recontroler implementation of the card in the PCI slot. PC is a desktop HP G5200uk PC. Windows 7 operating system.

    Hello

    The link below is a guige to install a video card in your Pc.  In particular, it seems that you will have to perhaps specify the location of the new card in the bios and save this change before you install the new card - see step 4 in the guide on the link below.  If your new card fits into the PCI Express x 16 slot, you will need to define PCI Express in the bios and save the changes.

    http://support.HP.com/us-en/document/c01700855

    Kind regards

    DP - K

Maybe you are looking for