Find a joint letter between two strings

Hello

I need help to find a common string between strings that results in a table. Here's an example scenario that you can consult to replicate and suggest.

create the table test_marine

(

P_ID varchar2 (50).

t_id varchar2 (50).

h_code varchar2 (40),

number of misc_type

);

insert into test_m values('1','100','ABC',1);

insert into test_m values('1','101','ABCD',1);

insert into test_m values('1','102','BC',1);

insert into test_m values('1','103','B',1);

COMMIT;

Data will look like below: -.

OTN.JPG

What I have to do here is - I want to take the all the h_code column values across both where p_id = 1 and browse all the values H_CODE one by one. Any other approach viable also who can help will be good.

Example - I choose ABC for 100, I check if A is common throughout 101,102,103, if so, save somewhere check then if B exists in all.

My Final result should be like this: -.

OTN2.JPG

Where there is more than one match: -.

OTN4.JPG

Where there is no match, the value may come as something as below: -.

otn3.JPG

Appreciate the help. Thank you

2615593 wrote:

Hello

Alone with AB.

In this case, you also want to...

insert into test_m values('3','100','ABC',1);
insert into test_m values('3','101','ABD',1);
insert into test_m values('3','102','ABE',1);
insert into test_m values('3','103','ABFG',1);
COMMIT;

SQL > ed
A written file afiedt.buf

1 with split as (select p_id
2, substr (h_code, level 1) as ch
3, count (distinct t_id) on (p_id partition) under the name of grp_cnt
4 of test_m
5 connect by p_id = prior p_id
6 and t_id = prior t_id
7 and level<=>
sys_guid() 8 and prior is not null
9                )
10, grp as (select p_id
11                     ,ch
12, count (*) as ch_cnt
13, grp_cnt
14 split
Group 15 of p_id, ch, grp_cnt
16              )
17 select m.p_id
18, listagg (nvl (grp.ch, 'None')) within the Group (ch control) as ch
19 m (select distinct test_m p_id)
20 left outer join grp (grp.p_id = m.p_id and grp.ch_cnt = grp.grp_cnt)
21 * group by m.p_id
SQL > /.
P_ID                                               CH
-------------------------------------------------- --------------------
1                                                  B
2                                                  None
3                                                  AB

3 selected lines.

Tags: Database

Similar Questions

  • Find the minimum distance between two SDO_GEOMETRY in Oracle Spatial?

    annular ring edit.png

    A circle (SDO_GEOMETRY)
    B - polygon (SDO_GEOMETRY)

    CASE:
    B contains A (or)
    The Interior of B.

    How to find the minimum distance between A and B in Oracle Spatial

    Hello guuid nameless person.

    What is

    my_answer := MDSYS.SDO_GEOM.SDO_DISTANCE(
       my_circle_geometry
      ,MDSYS.SDO_UTIL.POLYGONTOLINE(my_outer_polygon)
      ,my_tolerance
    );
    

    Now, you may need to pay attention to the holes in your polygon, would you the distance and an inner ring if it was closer to you?

    If the measure is only to outer rings, so something like

    my_answer := MDSYS.SDO_GEOM.SDO_DISTANCE(
       my_circle_geometry
      ,MDSYS.SDO_UTIL.POLYGONTOLINE(
          MDSYS.SDO_UTIL.EXTRACT(my_outer_polygon,1,1)
       )
      ,my_tolerance
    );
    

    And then also beware of the multipolygons as the foregoing only measured against the first polygon in the MultiPolygon.  You need to loop through the polygons of tests just the outer ring in this case.

    See you soon,.

    Paul

  • Find the intersection/union between two cards

    Hello.
    I'm trying to find out the changes of State between the two cards.
    I have two cards A and B, what I need to do is to find keys in A that exists in key and B in B that does not exist in a..
    If the key exists in both A and B I want to compare the values of these keys.
    What would be the most effective way to apply it.
    My first plan was to make a loop on the keys has to find b and browse the keys b and find in A, but I guess that there is a more efficient algorithm.
    I think also on the use of java.util.Collections to find union-intersection between the keys in the cards, but then I need to do a search in the two
    maps.
    Any suggestions?
    Concerning
    / Fredrik

    Fredrik wrote:
    My script is as follows:
    I am writing a Swing application for administration of a clustered environment.
    The keys in the map contains the ip address of the cluster nodes, the value is a State of a node in the cluster.
    I want to report the change of State of the node in the GUI.
    A state change occurs if there is a new node in the cluster, which means a new entry to the card since the last audit, or if a node
    Let the cluster has remove entry on the map since the last audit, or if the situation or condition for entry/ip has changed since the last audit.
    Concerning
    / Fredrik

    By your senario above, I don't think that you have two objects on the map, there is a single object and you want to report the change in the GUI, whenever an object is the value added, deleted or by itself is changed (key is the same) to the map.

    Then, I suggest below things:
    (1) override hashcode and equals method. (Because each time the methods put and putAll are called the hash code equal method checks in the bucket for the equal and similar hash code and if its equal, and then change the GUI for the existing map).
    (2) as suggested earlier, substitute methods of deletion. (Whenever an object is deleted, accordingly you can change the GUI).
    (3) as was suggested earlier, override a method put and putAll (whenever a new object is added, so you can change the GUI).

    And to do this, I don't think you have to browse the map.

  • Find the time delay between two signals

    In this code, I sent you a pulse in the acquisition of data using labview. The pulse triggers a thermistor to another analog input input data.

    I want to find the delay between the time of the positive edge of the switch, and the exact time of the DAQ begins to take in the signal of the temperature probe.

    I enclose the code below.

    Thank you.

    Hey,.

    Here is a link to some information about the sources of clock on the FPGA.

    http://digital.NI.com/public.nsf/allkb/94CE338CC80ACF008625791400516BAA?OpenDocument

    Hope this helps

  • find points of overlap between two graphs

    Hello.

    I would like to find points of overlay on my chart.

    I am simulating sinuses, and I have sampled sine of my instrument.

    On the graph, I see overlay points, which are not exactly the same, with some tolerance.

    I want to it marked on the chart. Is this possible?

    Or simply to store these equal (with a tolerance) samples in the table?

    I tried to use compare with tolerance, but without success.

    Best regards

    Kristina,

    If you are just interested in finding the points that correspond, simply compare the two VI as indicated below.

  • E/s Ethernet between two computers

    I have two computers running labview. I'm trying to generate a signal on one and read it on the other. Connection between two computers is ethernet. The problem is that NEITHER MAX cannot detect a network device. I have ping successfully the signal sent to the computer via the command prompt. Any ideas on why MAX can't detect the signalling computer?

    Try running the examples on the same machine. If you can't find the example works between two instances of the application of different on the same computer, then you certainly won't operate on two different machines. Once it works, try using the IP address instead of the host name of the computer. If still no luck, try disconnecting all other networks on both machines.

  • find the distance between two major axis chart point cloud

    Hello

    I have a scatter chart. Its the y-axis AutoScale property is set to false. The major and minor axes are by default. Interval is set by default.

    When draw the graph divisions displayed on the axis are defined according to the range provided. Sometimes, the interval between the major divisions, that is exactly what is defined in the Interval property and sometimes this isn't the same thing. As mentioned in the help the AutoScale property is set to true, sometimes by himself in order to avoid the congested labels.

    What I find is the distance beween two major axes of the value axis, as the interval is not the same as set in the property.

    Kindly let me know how to calculate the interval.

    Kind regards

    Nihad.

    yAxis1.AutoSpacingMajorInterval

    Replace yAxis1 by what is called your axis y on the scatter graph. If you don't know what it is, right click on the axis are the scatter graph, and then select Edit YAxes. Then a box will appear and you can see how it's called in the members section.

  • Regular expression help please. (extraction of a subset of the string between two markers)

    I haven't used regular expressions before, and I can't find a regular expression to extract a subset of the string between two markers.

    The chain;

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    6 ERRORS
                         
    Info I want to line 1
    Info I want line 2
    Info I want line 3
    Info I want to line 4
    Info I want to line 5
    Info I want line 6
    END_ERRORS

    From the string above (it is read from a text file), I try to extract the subset of string between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number from 1 to 32, and the number of lines I want to extract will correspond with this number. I can provide this number of a caller VI if necessary.

    My current solution, which works, but is not very elegant;

    (1) using Match Regular Expression for the return of the string after you have synchronized the 6 ERRORS

    (2) uses the Regular Expression matches to return all characters before game END_ERRORS of the string returned by (1)

    Is there a way this can be accomplished using 1 Regular Expression Match? If so someone could suggest how, as well as an explanation of the work of the given regular expression.

    Thank you very much

    Alan

    I used a character class to catch any word or whitespace characters.  This put inside parentheses a substring matching the criteria that you can get by developing the node for regular expression matching.  The \d matches the numbers and the two * s repetition of the previous term.  So, \d* will find the '6', as well as "123456".

  • How to find a number between two numbers?

    I try to find the numbers between two given user numbers and multiply each of them, but my code so far wont allow me to separate the numbers multiply:

    ex: the numbers are 5 and 10: my code gives me 5678910 together online.

    How can I sneek the * between these numbers? I know that I am seriously close here's my work so far.

    Any help is greatly appreciated.


    import java.util.Scanner;

    public class FindIt
    {
    Public Shared Sub main (string args [])
    {
    Console scanner = new Scanner (System.in);

    int userNumber, finIn, finIn2, finIn3;

    System.out.Print ("enter a lower limit > = 1 :"); ")


    do
    {

    userNumber = console.nextInt ();

    If (< 1 userNumber)
    {
    System.out.Print ("enter a lower limit > = 1 :"); ")
    }

    } while (< 1 userNumber);

    System.out.println ("the lower limit is" + userNumber);
    System.out.println ();
    System.out.Print ("enter an upper limit > = 3 :"); ")
    finIn = userNumber;
    do
    {

    userNumber = console.nextInt ();

    If (userNumber < 3)
    {
    System.out.Print ("enter an upper limit > = 3 :"); ")
    }

    } While userNumber < 3.

    System.out.println ("the upper limit is" + userNumber);
    System.out.println ();
    finIn2 = userNumber;



    int x, y;
    y = 0;
    for (x = finIn; x < = finIn2; x ++)

    CallIncr();





    }
    }

    Published by: 806590 on October 31, 2010 13:07

    Published by: 806590 on October 31, 2010 13:09

    Modified the code of the loop to as below

    for (x = finIn + 1; x)< finin2;="">

  • Find the difference between two date and time

    Hi friends,

    I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."

    select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed  
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate) 
    order by sql_step_num;

    You try to get the feel between two char strings.
    And more difference between two dates gives a NUMBER of days.
    Try this:

    select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate)
    order by sql_step_num;
    
  • How to find directions between two locations other than my current position. I finally gave up and use Google Maps.

    In the latest version of cards, there is not apparent until you find directions between two places when or is your current position. In earlier versions, we enter in two places of departure and destination. In the new version, you enter your destination into a search window, but there is no place to enter a starting location. The application assumes that your current place of residence is always your place of departure. It is a remarkable oversight by designers. Am I missing something?

    If you go to maps, you can search for a location. Once you find the place, press the route button. It is from your current location, but if you type on my position, next: you can change the location that you want the management of.

  • find the difference in days between two dates

    Hello world

    I'm trying to find out the difference in days between two dates and the execution of the query that I'm passing

    SELECT TO_char(sysdate, 'dd/mm/yyyy') - TO_char('15/11/2011', 'dd/mm/yyyy') DAYS FROM DUAL

    the error I get is

    ORA-01722: invalid number
    01722 00000 - "invalid number."
    * Cause:
    * Action:

    Could someone please help.

    Thanks in advance

    user10636796 wrote:
    Hello world

    Thanks a lot for all the replies. I am trying to apply it in a statement to my table like this

    SELECT trunc (sysdate) - TO_char (date_last_recommended, ' dd/mm/yyyy') DAYS OF recommendation;

    SELECT trunc (sysdate) - TRUNC (date_last_recommended) DAYS OF recommendation;

  • How do you find the average value of all the data between two points on a single channel

    I'm tring to calculate the average value of all data points in a single field between two distinct points

    I rasthaus an illustration.

    Hi smoothdurban,

    I thought you wanted to specify the area of interest with the sliders of the band.  If you rather automatically define the area of interest based on thresholds, etc., we cannot see the interactive nature of the example I sent.

    What are the criteria used to determine the start and end of the region of interest lines?

    I would be able to type this out for you if you sent a representative data set ([email protected])

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • Find the time to intersampling between two channels AI USB 6251

    Hello

    I want to know how late it is between two-channel sampling of HAVE in a USB-6251 (term mass) used in conjunction with a block of connection SCB - 68 (Labview 8.5, Windows XP).  I realize that there's only an ADC and simultaneous acquisition is not available.  The specs are listed as follows:

    Sampling frequency:

    Maximum: 1.25 MECH. / s single channel;  1,00 multi-channel MECH. / s (aggregate)

    Minimum configuration: no minimum

    Timing accuracy: 50 ppm of sampling frequency

    Temporal resolution: 50 ns

    We know of a way to understand this point other than by experimentation?

    See this

  • How to find days between two dates in days

    Hi, I want to get the days between two dates, expressed in days, how can I do this?  For example, I date i.e. 1 October 10, 2013 (Thursday) and 2 as October 13, 2013 (Sunday).  How can I get a production of:

    Thursday, Friday, Saturday and Sunday, which are the days between Oct. 10-13, 2013.  I hope you understand my point.  Thank you

    You can try something like this

    CURSOR LOAD_PROF is

    SELECT load_prof1, v_time_profile_day

    OF load_profile_test

    WHERE profile_day IN (select TO_CHAR(:day1+level-1,'Day')

    of the double

    connect by level<>

    );

    Kind regards

    S Pax

Maybe you are looking for