How to find the union between 2 strings

Hello


Here are 2 string as a samble of my 2 tables,
1 (; 1; 10; 2; 3; 4; 5; 7; 8)
2 (; 10; 2; 3; 4; 5; 8; 9)

I need to find the union between these 2 strings, the result should be
result of the union = (; 1; 10; 2; 3; 4; 5; 7; 8; 9)

any help please,.

Hello

Sorry; until you have validated your tables, I couldn't test it.
I forgot to attach cntr to each of the other tables. (It's all the interest to generate cntr in the first place).
That's what I should have posted:

WITH     cntr     AS
(
     SELECT     LEVEL AS n
     FROM     dual
     CONNECT BY     LEVEL <= 10
)
SELECT     REGEXP_SUBSTR ( a.txt_a
                , '[^(;)]'
                , 1
                , ca.n
                )          AS itm
FROM          table_a     a
CROSS JOIN     cntr     ca
     --
    UNION
     --
SELECT     REGEXP_SUBSTR ( b.txt_b
                , '[^(;)]'
                , 1
                , cb.n
                )          AS itm
FROM          table_b     b
CROSS JOIN     cntr     cb
;

Output given your sample data:

ITM
-----------------

1
2
3
4

Tags: Database

Similar Questions

  • How to find the Union between the column in the table

    Hello

    I have the followin table and I want to find the union between the lines as below,
    create table test5 (tidset varchar2(200));
    
    insert into test5 values('1;2;3;4;5;6;7;8;9;10;11;12;13;15;16;17;18;19;20');
    insert into test5 values('1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20');
    insert into test5 values('1;2;3;4;6;7;8;9;11;12;13;15;16;19;20');
    insert into test5 values('1;4;6;10;6;11;12;13;14;15;16;17;18;19;20');
    I need the result to be as below.
    1;4;6;11;12;13;15;16;19;20
    any help please,.

    Published by: user11309581 on November 17, 2011 21:32

    Always mention what version of oracle you are using.

    The following query will give you the desired result oracle version 11g release 2.

    Connected to Oracle Database 11g Release 11.2.0.2.0 
    
    SQL>
    SQL> with test5 as
      2  (
      3  select '1;2;3;4;5;6;7;8;9;10;11;12;13;15;16;17;18;19;20' tidset from dual union all
      4  select '1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20' from dual union all
      5  select '1;2;3;4;6;7;8;9;11;12;13;15;16;19;20' from dual union all
      6  select '1;4;6;10;6;11;12;13;14;15;16;17;18;19;20' from dual
    -- "END OF SAMPLE DATA"
      7  ), all_items as
      8  (
      9    SELECT regexp_substr(t.tidset, '[^;]+', 1, column_value) item
     10          ,t.tidset
     11      FROM test5 t
     12          ,TABLE(CAST(MULTISET
     13                      (SELECT LEVEL
     14                         FROM dual
     15                       CONNECT BY LEVEL <=
     16                                  length(regexp_replace(t.tidset, '[^;]')) + 1) AS
     17                      sys.odcinumberlist))
     18  ),item_counts as
     19  (
     20    SELECT DISTINCT a.item
     21                   ,COUNT(DISTINCT a.tidset) over() total_tidset
     22                   ,COUNT(a.item) over(PARTITION BY a.item) item_occurance_count
     23      FROM (SELECT DISTINCT item
     24                           ,tidset
     25              FROM all_items) a
     26  )
     27  SELECT listagg(item, ';') within GROUP(ORDER BY to_number(item)) common_items
     28    FROM item_counts
     29   WHERE total_tidset = item_occurance_count
     30  ;
    
    COMMON_ITEMS
    --------------------------------------------------------------------------------
    1;4;6;11;12;13;15;16;19;20
    
    SQL> 
    

    OR if you have any version of oracle less than 11g release 2 then replace below mentioned line

    SELECT listagg(item, ';') within GROUP(ORDER BY to_number(item)) common_items
    

    with this one

    select xmlagg(xmlelement(c,item||';').extract('//text()') order by (to_number(item))) common_items
    

    It is because the listagg function used in above query is not supported in versions of oracle 11.2 below.

    I hope this helps.

    -Gregory

    Published by: Mohamed Diarra on November 18, 2011 01:05
    Extra line to be changed for the oracle version lower than 11.2

  • How to find the difference between standard edition and standard edition one

    How to find the difference between oracle database standard edition and standard edition one 64 bit

    (a) using sql
    (b) using the configuration/installation files

    How to find the difference between oracle database standard edition and standard edition one 64 bit

    (a) using sql

    Select * the option of $ v;

    (b) using the configuration/installation files

    opatch lsinventory-details

  • How to find the relationship between the tables

    Hello
    I am working in Oracle R12

    How to find the relationship between these tables INV_MIN_MAX_TEMP, po_requisition_lines_all and Per_all_people_f

    These two tables, I joined with po_requisition_lines_all and Per_all_people_f To_person_id of PO and anyone HR table but I can't able to join this table with other tables INV_MIN_MAX_TEMP

    concerning
    Srikkanth

    solved

  • How to find the difference between related areas

    Hi all
    My problem is I have a table in which each woman will be visited maximum 8 times, each woman may or may not
    given a reference in any visit which in turn women will respond to this referral in a next visit
    (not necessarily the next visit), I need to calculate the average number of visits between the visit
    in which the wife received a refferal and visit in which she responds.

    as an example

    woman_id visit_id given_referral respond_to_referral
    -------- -------- -------------- -------------------
    1 1 TRUE NULL
    1 2 TRUE TRUE
    1 3 TRUE NULL
    1 4 TRUE NULL
    1 5 NULL NULL
    1 6 TRUE NULL

    This means that visit 2 response is referral to visit 1 so the difference is 1.
    and the visit 6 response corresponds to the referral in visit 4 so the difference is 4.
    what I can't do is knowing how to know answer to visit 6 associated reference visit 4 No 1 or 2 or 3...

    and I need to find the following table of the foregoing

    woman_id difference between referral and response
    ---------          ---------------------------------------
    1                    1
    1                    2

    quick access to help please

    Published by: M.Jabr on December 14, 2009 08:05
    with t as (
               select 1 woman_id,1 visit_id,'TRUE' given_referral,NULL respond_to_referral from dual union all
               select 1,2,'TRUE','TRUE' from dual union all
               select 1,3,'TRUE',NULL from dual union all
               select 1,4,'TRUE',NULL from dual union all
               select 1,5,NULL,NULL from dual union all
               select 1,6,NULL,'TRUE' from dual
              )
    select  woman_id,
            diff
      from  (
             select  woman_id,
                     visit_id - last_value(case
                                             when given_referral is not null
                                               then visit_id
                                           end
                                           ignore nulls
                                          )
                                over(
                                     partition by woman_id
                                     order by visit_id
                                     rows between unbounded preceding and 1 preceding
                                    ) diff,
                     respond_to_referral
               from  t
            )
      where respond_to_referral = 'TRUE'
    /
    
      WOMAN_ID       DIFF
    ---------- ----------
             1          1
             1          2
    
    SQL> 
    

    SY.

  • How to find the bytes in hexadecimal string start

    Hi, I'm a freshman for Labview.

    I want to find the beginning bytes in Hex string. For example, 12 1A 00 34 1A 01 23... How can I get my data of 3 bytes of the hexadecimal string which starts at 1 'a '?

    Thank you for your help.

    You will need to provide more information. You have a string that has values of bytes like this? In other words, you have the control/indicator string value "hex display mode", and that you have provided, that's what you have? Or, you have the string in normal view?

    If it is in hexadecimal display mode, then use one of the functions of the chain to get a subset of the string. Have you looked in the channel palette?

    If it is in normal display mode, then you must convert all 2 characters to hex values.

    To learn more about LabVIEW, it is recommended that you go through the tutorials and look over the material in tutorials the NI Developer Zone Learning Center , which provides links to other materials and other. You can also take a course online for free.

  • How to find the time between two channels of entry in the data acquisition card or pci 6036

    Hello

    I read a lot-related posts on the simultaneous measurement of two input voltage of similar channels in map data acquisition. I know that the best material is "simultaneous measurments of the Series DAQ cards" but I only pci data acquisition card 6036 and I try to understand what is the time between the reading of the two channels . This period is always constant? (must it rely on a voltage (amplitude, frequency, waveform..). I send the sine wave (s) to the two channels and read the values of V, if they read the same value, the difference should always be zero but I get-0,002 to 0.002 Volt difference (I must find a way to convert it in time). A screenshot of my VI is attached. I wonder how I can accurately measure the time delay between the channel.

    I am open to any suggestion, my final goal to read exactly two channels at the same time ((ou connaître le délai exact donc je peux correspondre les données correspondantes étant donné le temps de retard))

    Hi spinup,

    better you should post your question in the forum of LabVIEW, LabWindows/CVI is used

    Good luck.

  • How to find the Distance between the two stores

    Hi all

    I need to find out the distance between stores in our organizations. For example, for a store and shop B, distance of 5 miles etc...

    I'm very very new in Oracle Spatial and don't know how to do it.

    Can you help me please?

    Kind regards

    Dilek

    Dilek,

    That have you tried that didn't work?

    See: package SDO_GEOM (geometry)

    Bryan

  • How to find the difference between two dates in time except Sunday

    Hi all

    I have a table, as shown below.
    SQL> select * from test;
    
    TR_ID                                              CREATE_TIME                                                                       CODE
    -------------------------------------------------- --------------------------------------------------------------------------- ----------
    S12341                                             05-JUN-12 12.20.52.403000 AM                                                      1003
    S12342                                             11-JUN-12 11.15.33.182000 AM                                                      1003
    S12342                                             07-JUN-12 12.00.36.573000 PM                                                      1002
    S12343                                             20-JUN-12 12.34.37.102000 AM                                                      1003
    S12343                                             15-JUN-12 11.34.27.141000 PM                                                      1002
    S12344                                             01-JUL-12 10.01.06.657000 PM                                                      1002
    S12344                                             06-JUL-12 12.01.04.188000 AM                                                      1003
    S12341                                             31-MAY-12 11.20.38.529000 PM                                                      1002
    I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.

    For example:

    TR_ID: S12344
    1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
    1003_Create_time: 12.01.04.188000 AM 6 July 12

    1002 create time is 22:00 Sunday.

    If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.

    I tried the sub query after doing a search on this forum but I am not getting the desired output.
    SELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and 
    ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) 
    from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d 
    WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
    Need help to get the desired o/p

    Hello

    If I unederstand the problem correctly, that's what you want:

    WITH       got_extrema     AS
    (
         SELECT       tr_id
         ,       CAST (MIN (create_time) AS DATE)     AS start_date
         ,       CAST (MAX (create_time) AS DATE)     AS end_date
         FROM       test
         GROUP BY  tr_id
    )
    SELECT       tr_id
    ,       start_date, end_date          -- If wanted
    ,       24 * ( ( ( TRUNC (end_date,   'IW')          -- Count -1 day for every full week
                        - TRUNC (start_date, 'IW')
                 )
               / -7
                  )
                + LEAST ( end_date               -- If end_date is a Sunday
                            , TRUNC (end_date, 'IW') + 6     -- consider it 00:00:00 on Sunday
                     )
                - CASE
                          WHEN  start_date >= TRUNC (start_date, 'IW') + 6     -- If start_date is a Sunday
                   THEN  TRUNC (start_date, 'IW') + 6               -- consider it 00:00:00 Sunday
                   ELSE  start_date
                      END
                )     AS total_hours
    FROM      got_extrema
    ;
    

    I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.

    Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
    (a) 1 day is deducted for each week between start_date and end_date
    (b) if End_date is a Sunday, none of the end_date himself hours are counted
    (c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.

    TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.

    Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • How to find the mode of a string array

    Hey guys,.

    Then I came across this little problem that I thought I could solve easily enough, but it turned quite messy.

    I have this array of strings, and I want to find the most frequent entry in this array. Let's say I have the following table.

    Apple

    Apple

    Kiwi

    Orange

    Apple

    the mode would give me apple. I thought to convert the strings into a number and then find fashion as usual.

    But if the chain is too long, it seems a superelevation of unique number used to represent.

    Any ideas on a clean way to do this?

    This can also work

    Nick

  • How to find the ratio between the two frequencies in the fft

    Hi, I'm Jean,

    I need to find the ratio of the frequencies of 1st and 2nd graph fft.

    Already, I received information of this site only. Mr. Alten helped me.

    Now, I have to continue the same problem and need to find the ratio of the frequencies.

    Please someone help me guys...

    I will attach my vi file and the text file.

    John,

    Should you report the frequencies or the report of the amplitudes of the components at these frequencies?

    The Information.vi of your multiple for the Signal Processing, extract > range of measures of waveform should do what you want.

    The frequency resolution is not very good because you have cycles relatively little waveforms (2 ~ for the lower frequency). I added a few zeros to improve resolution, even if a larger sample of data would be better.

    Lynn

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • How to find the difference between the two timestamp columns

    Dear all,
    Please solve my problem,
    I have Table name of the folder that has the following columns,
    EmpID in the number column, timestamp dat
    who has the following values
    Expand | Select | Wrap | Line numbers
    EmpID dat
    ====== ====
    101 4/9/2012 09:48:54
    101 4/9/2012 09:36:28
    101 4/9/2012 18:16:28
    101 4/10 / 2012 09:33:48
    101 4/10 / 2012 12:36:28
    101 4/10 / 2012 20:36:12
    101 4/11 / 2012 09:36:28
    101 4/11 / 2012 16:36:22
    Here, I need to display the following columns

    EmpID, min (DAT) as start, max (dat) as end and difference (max (dat) - min (dat) for each day,
    for example,.
    End difference EmpID Strart
    101 4/9/2012 09:48:54 09/04/2012 18:16:28 8.28
    Like this.
    3 days different here is so it should return 3 discs with the mentioned columns above,
    Please help me find it.

    Thank you
    Kind regards
    Gurujothi

    Published by: Gurujothi on April 25, 2012 04:45

    Gurujothi wrote:
    Dear Alex,
    Thank you for your reply,
    Depending on whether you are your quesy showing it in hour and minutes format its right but you mention all rows of the query
    If the table has more than 3000 lines then how it is possible to write this much higher request,
    my table with almost 3500 lines.

    You can make a few changes in the above query I posted the last I mentioned?

    Thank you.

    Published by: Gurujothi on April 25, 2012 23:18

    Hello

    You don't need to write whole records 3000 it... alex just wrote that for example have no table as your table...
    so just use the under part of this query as in the previous post, alex:

    select empid, trunc(dat),
           min(dat) as start_dat,  to_char(min(dat), 'hh24:mi:ss') as start_dat_part,
           max(dat) as end_dat, to_char(max(dat), 'hh24:mi:ss') as end_dat_part,
           max(dat)-min(dat) diff, to_char(max(dat)-min(dat), 'hh24:mi:ss') diff_part,
           extract(day from max(dat)-min(dat)) || ' days'
           || ':' ||  extract(hour from max(dat)-min(dat)) || ' hours'
           || ':' ||  extract(minute from max(dat)-min(dat)) || ' mins'
           || ':' ||  extract(second from max(dat)-min(dat)) || ' sekas'
    from trans
    group by empid, trunc(dat)
    

    hope this fixes your need

  • How to find the hours between two times

    Hai All

    I had a problem I need to calculate work time

    For example

    Respondent outtime

    0815 1715

    So I need to calculate a time between these two times

    How can I do using function for 100 our

    Concerning

    Srikkanth.M

    Hello

    use the below the update statement.

    update dail_att set wtime =  extract(hour from (to_date(outtime,'HH24:MI')-to_date(intime,'HH24MI')) day to second);
    

    Solution of the sample...

    PRAZY@11gR1> desc dte;
     Name            Null?    Type
     ------------------- -------- --------
     INTIME           VARCHAR2(4)
     OUTTIME        VARCHAR2(4)
     HRS                NUMBER
    
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715
    0900       1800
    0830       1630
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> update dte set hrs = extract(hour from(to_date(outtime,'HH24MI')-to_date(intime,'HH24MI')) day to second);
    
    3 rows updated.
    
    Elapsed: 00:00:00.01
    PRAZY@11gR1> select * from dte;
    
    INTIME     OUTTIME           HRS
    ---------- ---------- ----------
    0815       1715                9
    0900       1800                9
    0830       1630                8
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

    Published by: Prazy on March 24, 2010 12:43

  • How to find feel it between the elements in an array

    Hi guys,.

    It is easy for you probs, but how can you find the diffence between all elements in an array?

    for example array = 1 2 3 4 5 6

    so difference between 1 and 2 is 1, the difference between 1 and 3 is 2. all the way to the hollow of the differece between 6 and x is x etc.

    I tried using shift registers, but just can't get enough.

    Thank you

    No need for the outer loop.

Maybe you are looking for

  • Why can't easily shoot to the top of the sidebar of history more?

    Since the latest Firefox and nightly updates, the orange box "Firefox" is more in the upper left corner of the screen. So whereas before I could access what without keeping the menu bar at top, now I am limited in my selections. The main thing I'm wa

  • Presentation starts 5 "on the left side of the screen and shoot intellegence off-screen to the right.

    The top of my screen is normal: starts the toolbar 'File, Edit... '. The body of the screen during execution of Firefox - and as I type this message - is full of lite. The actual data: starting at the top of this page: "Firefox Help...". Request a ne

  • How to reduce the length of loop of HP

    Hello I'm running a model with a rate of 5 kHz in a quad core 2 to 2.6 GHz computer. If I put in "parallel" run mode model County is growing rapidly but the model rate keeps at 5 kHz. Changing the mode of execution of "Low latency" model remains at 0

  • cDAQ9188 in C

    Hi all I am trying to run cDAQ9188 with 03 OR 9205 modules installed on it in a single task (for automatic synchronization) using the given C API by NOR. For the NI 9205 single module installed on cDAQ9188, following works fine: ......... DAQmxErrChk

  • MX 920 does not print

    Just bought a new MX920 and implemented following the indications of the clos.  It will not automatically adjust head alighment.  In fact, I can't print anything at all.  No matter what I try, it feeds a blank page. I think I missed somehing in Setup