Compare the column values for multiple lines

I am new to oracle and I have a requirement to compare the values of column across multiple lines.  If all column values are the same, I want to display that value, if the columns are not the same, I need to display 'no match' as value.   I need id to group values and display a status value based on the above logic.   Can anyone offer assistance with dispalying the result expected below?

Sample

Table

State ID

1         S

2         L

1         S

2          S

expected results

State ID

1         S

2 no match


Advertisement

Hello

That's what you asked for:

SELECT id

CASE

WHEN COUNT (DISTINCT status) > 1

THEN "no match."

For ANOTHER MIN (status)

The END as status

T

GROUP BY id

;

Want that if each State ID is NULL?  The CASE expression above returns NULL in this situation.

Tags: Database

Similar Questions

  • Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Hello

    2796614 wrote:

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Of course, it is possible.  According to what the text file looks like to, you can create an external table that treats the text file as if it were a table.  Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.

    You have problems whatever you wantt?  If so, your zip code and explain what the problem is.

    Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas.  In this case, also post a small sample of the text involved file.

    If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • convert the column values to a single line...

    I have to return the column values to a single line separated by commas.
    If the nulls in the column just ignore without a comma.
    Here is one for example. There are three values and two NULL values in the table
    SQL> select ID from temp_fa;
    ID
    -----
    
             1
             2
    
             3
    
             5
    
    6 rows selected.
    
    
    I am expecting an output as 1,2,3,5
    Help, please

    There is always more than one title in the Oracle world ;)
    You can use the TRIM, for example (same configuration as your example):

    hoek&XE>  create table t as select level col  from dual connect by level <= 6;
    
    Tabel is aangemaakt.
    
    hoek&XE> update t set col = null where col in (1,3,5);
    
    3 rijen zijn bijgewerkt.
    
    hoek&XE> select * from t;
    
           COL
    ----------
    
             2
    
             4
    
             6
    
    6 rijen zijn geselecteerd.
    
    hoek&XE> select ltrim(sys_connect_by_path(col, ','), ',') output
      2  from  ( select col
      3          ,      row_number() over (order by col) rn
      4          from   t
      5        )
      6  where connect_by_isleaf=1
      7  start with rn=1
      8  connect by rn = prior rn+1;
    
    OUTPUT
    -------------------------------------------------------------------------------------------------------------
    2,4,6,,,
    
    1 rij is geselecteerd.
    
    hoek&XE> select trim ( both ',' from sys_connect_by_path(col, ',')) output
      2  from  ( select col
      3          ,      row_number() over (order by col) rn
      4          from   t
      5        )
      6  where connect_by_isleaf=1
      7  start with rn=1
      8  connect by rn = prior rn+1;
    
    OUTPUT
    -------------------------------------------------------------------------------------------------------------
    2,4,6
    
    1 rij is geselecteerd.
    
  • Get the value based on the column names for the custom of the Webcenter content metadata field

    University Complutense of MADRID, I created a custom text metadata field.  I then activated optlist this area.  I fill the optList values, I use a view.  The view has three columns.  Let us call their ID, Key, Value.  OptList shows keys in its list.  I then create content (Content ID: MyContent) Webcenter content and choose the OptList values for my new field of metadata (MyField).

    WebCenter portal, I'm filling a selectOneChoice with MyField values in the content ID: MyContent.  Remember the previous step, the values entered in selectOneChoice lists them selected values from the field MyField optList.  The optList is filled from view.  After the user selects a value in selectOneChoice, in Javascript, I need to alert a message in this format "selected value - matching value from the view of the optList that fills MyField.

    In my opinion, only an example will be useful:

    This is a view that I created in Configuration Manager applet in Webcenter content Admin cmdlets :

    ID | State | Capital

    1. North Carolina | Raleigh

    2. California | Sacramento

    3. Illinois | Chicago

    Then I create a custom field (name: MyField).  MyField is an optList values are filled with view created above.  Internal value and the display value are the two State.  Then I have a new content with Content Id Check-In: MyContent.  To MyContent, I select these values in OptList MyField: {North Carolina, Illinois}.

    In my portal Webcenter application, I create a Taskflow presenter content.  I have set up as single content item presenter.  I attribute as content ID MyContent.  Then, in templateView, I get all the values of MyField in MyContent and display as selectOneChoice.  I created a javascript function that would get the value that the user selected in selectOneChoice.  In the view created in the Webcenter content Configuration Manager (see above), there is a value corresponding to each displayed value.  So, for the selected value, I need to get the corresponding Capital and display in my alert message.

    Starting from Javascript, how can I get the value of the Capital, since I have the status value.

    Hello.

    The idea to reach your requirement is planned:

    • Create an Assistant manage bean that will appeal as access map: #{stateUtil ['Calofironia']} (it will return Raleigh). This value will get calling GET_SCHEMA_VIEW_VALUES IDC service using RIDC in your managed bean.
    • Pass the result of #{stateUtil ["statename"]} to your JavaScript function to help

    I hope this information help you.

    Kind regards

  • How can I change the pdf file cannot be modified, but hold down the scroll button for the form fields with multiple lines?

    I need all the information to display so I need the scroll key to work, but it is not editable.

    Thanks for the help!

    Tania

    You can define a field with strike and validate to prevent the user from changing the value of the field. First, set the field to multiline and 'Scroll long text' and the default value for the text to display in the field. Then add a custom script to strike which is:

    Custom keystroke script

    Event.RC = false;

    and to be complete, the validation script customized according to:

    Custom validation script

    If (event.value! == event.target.defaultValue) event.rc = false;

    These scripts will prevent the value to be changed, at least in Acrobat and Reader if JavaScript is enabled.

  • Comparison of column values for Char and numbers

    Hello

    I have a requirement to compare the columns of the two tables value as described below-

    Table - T1 (NAME VARCHAR2, VARCHAR2 VALUE)
    NAME    VALUE
    A       1
    B       ABC
    C       2
    D       XYZ
    Table - T2 (NAME VARCHAR2, VARCHAR2 VALUE)
    NAME    VALUE
    A       1
    B       ABCD
    C       4
    D       XYZ
    Column 'NAME' is unique in the two tables. The comparison must exact match for the values of character ("ABC" = "ABCD", "XYZ" = "XYZ"), but in the numerical values, there must be a comparison of the value (T1. VALUE < T2. (VALUE).

    For example, the output from the example table above should be-
    T1.NAME    T1.VALUE    T2.VALUE
    A          1           1
    C          2           4
    D          XYZ         XYZ
    Thank you for your time and please let me know if any necessary clarification.

    Khayyam wrote:
    you mean that the following output?

    C     2     4
    D     XYZ     XYZ
    

    Because T1. VALUE< t2.value="" (1="" not=""><>

    Try this:

    WITH t1 AS (SELECT 'A' name, '1' VALUE FROM DUAL
    UNION
    SELECT 'B', 'ABC' FROM DUAL
    UNION
    SELECT 'C', '2' FROM DUAL
    UNION
    SELECT 'D', 'XYZ' FROM DUAL),
    t2 AS (SELECT 'A' name, '1' VALUE FROM DUAL
    UNION
    SELECT 'B', 'ABCD' FROM DUAL
    UNION
    SELECT 'C', '4' FROM DUAL
    UNION
    SELECT 'D', 'XYZ' FROM DUAL)
    SELECT *
    FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
    FROM t1 JOIN t2 USING (name)
    WHERE NOT REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
    WHERE t1val = t2val
    UNION
    SELECT *
    FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
    FROM t1 JOIN t2 USING (name)
    WHERE REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
    WHERE t1val < t2val
    

    Note that this will work in 10G and 11G (supported regular expression) databases.

    Add<= then="" op="" expected="" output="" will="" come="">

    WITH t1 AS (SELECT 'A' name, '1' VALUE FROM DUAL
                UNION
                SELECT 'B', 'ABC' FROM DUAL
                UNION
                SELECT 'C', '2' FROM DUAL
                UNION
                SELECT 'D', 'XYZ' FROM DUAL),
         t2 AS (SELECT 'A' name, '1' VALUE FROM DUAL
                UNION
                SELECT 'B', 'ABCD' FROM DUAL
                UNION
                SELECT 'C', '4' FROM DUAL
                UNION
                SELECT 'D', 'XYZ' FROM DUAL)
    SELECT *
      FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
              FROM t1 JOIN t2 USING (name)
             WHERE NOT REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
     WHERE t1val = t2val
    UNION
    SELECT *
      FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
              FROM t1 JOIN t2 USING (name)
             WHERE REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
     WHERE t1val <= t2valWITH t1 AS (SELECT 'A' name, '1' VALUE FROM DUAL
                UNION
                SELECT 'B', 'ABC' FROM DUAL
                UNION
                SELECT 'C', '2' FROM DUAL
                UNION
                SELECT 'D', 'XYZ' FROM DUAL),
         t2 AS (SELECT 'A' name, '1' VALUE FROM DUAL
                UNION
                SELECT 'B', 'ABCD' FROM DUAL
                UNION
                SELECT 'C', '4' FROM DUAL
                UNION
                SELECT 'D', 'XYZ' FROM DUAL)
    SELECT *
      FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
              FROM t1 JOIN t2 USING (name)
             WHERE NOT REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
     WHERE t1val = t2val
    UNION
    SELECT *
      FROM (SELECT name, t1.VALUE t1val, t2.VALUE t2val
              FROM t1 JOIN t2 USING (name)
             WHERE REGEXP_LIKE (t1.VALUE, '[[:digit:]]'))
     WHERE t1val <= t2val
    
    NAME T1VAL T2VAL
    ---- ----- -----
    A    1     1
    C    2     4
    D    XYZ   XYZ   
    
    3 rows selected
    
  • How to compare the new values with the old values in triggers.

    Dear all,

    Please tell me how to compare the new values with the old values in triggers.

    Hi, the employee example is in the document. You'd better read yourself.

    CREATE OR REPLACE TRIGGER Print_salary_changes
      BEFORE DELETE OR INSERT OR UPDATE ON Emp_tab
      FOR EACH ROW
    WHEN (new.Empno > 0)
    DECLARE
        sal_diff number;
    BEGIN
        sal_diff  := :new.sal  - :old.sal;
        dbms_output.put('Old salary: ' || :old.sal);
        dbms_output.put('  New salary: ' || :new.sal);
        dbms_output.put_line('  Difference ' || sal_diff);
    END;
    /
    
  • How to find out the ASCII values for the Spanish character

    Hello

    I had an obligation to maintain the Spanish character and must also always records based on the Spanish character.

    Kindly guide me for below.

    To filter the records that contains Spanish characters?
    To get the ASCII values for the particular column?

    For example, we can find the ASCII value of 'a' using the select syntax ASCII('a') double.

    But I want to find the value of the particular column ASCII values. That is to say. name.
    For example, the customer name is 'Suresh', I want the ASCII values for the entire name of 'Suresh '.

    Please do the necessary help / advice on that.

    Thank you
    Orahar

    To expand on what I said in my first post, you want to do something in this direction:

    with t (thename) as
      (
      select 'Suresh' from dual
      )
    select thename
         , substr(TheName, level, 1)
         , ascii(substr(thename, level))
      from t
    connect by level <= length(thename);
    

    The result of the above query is:

    THENAM S ASCII(SUBSTR(THENAME,LEVEL))
    ------ - ----------------------------
    Suresh S                           83
    Suresh u                          117
    Suresh r                          114
    Suresh e                          101
    Suresh s                          115
    Suresh h                          104
    
    6 rows selected.
    

    Note that the WITH statement is only there to simulate a table for this example. With a table, all you do is get rid of the with and replace it with the name of "t" for your table name (also the name of the column with name column has in your table).

    Finally, I suggest that you post your question with, an example of table and the output you want for PL/SQL forum. There are people out there who will give you all sorts of ways to solve this problem.

    HTH,

    John.

  • Convert the column values into buckets

    Hello

    Please help me to convert the column values into buckets.
    I have the values of the columns in the following way.


    Age of Orderdate * 9 10 12 14 15 18 19 20 21 22 26 27 28 29 33 34 40 45 * and so on



    But the requirement is the column values should be displayed in form

    Age by order date * 15 1 2 3 4 5 6 7 8 9 10 11 - 16-20 21-25, 26-30 30 + *.


    Please someone give me the solution.

    Thanks in advance.

    Hervé Rama

    Hi Richard,

    Just to double check, you have Setup buckets for 1, 2, 3, 4, 5, 6, 7 and 8 individually (each with a fair value). The problem is that you simply do not have all data fall into buckets above, correct?

    If this is the case, it looks like has been answered your original question. If so, the label would assign 'Proper' points by clicking on the button label correct next to the appropriate response and open a new thread with your new question. The reason why I say this is it will help other people who have a similar bucket question to your solution, without complicating the issue with subsequent questions.

    If you can post a separate thread, I'd be more than happy to help you with your secondary problem.

    Best regards

    -Joe

  • Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value?

    Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value? I need the actual default value for an individual preference.
    Topic: config shows some default values, but I need the source from which everything: config returns to the default value.
    Any help in this direction is greatly appreciated.

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x 64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The preferences that are not hidden if they have by default are stored in two JavaScript text files in the Firefox program folder
    You can open them in a tab in Firefox through these links:
    resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js

    (702598/forum/1/702598)

  • How can you specify the default value for the undefined array elements

    According to aid LV, the tables have two default values, the normal default value and the default value for the undefined array elements.

    I assume that there must be a way to specify the default value for later, but I can't find it anywhere.  Any ideas?

    I know that you can drag the item out of the table container.  Change the default value on this scalar element.  Then drag the item in table tank.

  • is it possible to save the Office XP for multiple monitors and restore after using the laptop in mobile mode?

    Is it possible to save the Office XP for multiple monitors and restore after using the laptop in mobile mode?

    Hi Kenelms,

    You can follow this link & check if it helps.

    HOW to: Set up hardware profiles for laptop computers in Windows XP

    Hope the helps of information.

    Please post back and we do know.

  • BlackBerry Z10 well defined, I can't get the phone to ring and vibrate as the default value for all calls. I can put individual contacts, but I want to ring and vibrate for all.

    Although the value, I can not phone ring and vibrate as the default value for all calls. I can put individual to vibrate and ring contacts and it works but I want as the default for all incoming calls. Any help would be appreciated, thanks

    Sorry, I found the answer in the manual

    "Change your ringtone, sounds or alerts.

    GoTo settings\notifications to the bottom of the screen select application\phone

    You can activate vibrate out there, put the ringer default etc.

  • Simulator Device.xml file has a tag with an attribute of memory, what are the optional values for this attribute of the os?

    In the Device.xml file, it starts with the tags of the os. Each os has a memory attribute. What are the optional values for the attribute memory?

    Can we really control the memory for the simulators?

    0x85000F03
    0x8C000F03
    0x87000F03
    0x84001503
    0x86001503
    0x04001507
    0x0F001507
    0x0C001404
    0x0D001404
    0x0E001404
    0x0D000D04
    0x16000D04
    0x05001504
    0x07001504
    

    These values refer to specific hardware configurations are simulated.  They should not be changed.

  • What are the optimal values for mac and arp timeout values

    Hi guys.

    What are the best values for 'mac address-table-time of ageing' and "arp timeout" by following scenarios? :

    -single sg300-10 as hosts Layer 3 - with a maximum of 10 local switch (directly connected)

    - and a 3750 x-stack with 100 local hosts + hsrp with a battery of the same kind

    or for asa 5520 as internet gateway for 500 customers?

    I use now a time of aging mac 300 seconds and a time-out of the arp of 3600 seconds.

    Is - this okay.?

    Thank you.

    These values should be fine. I don't know why the switch is layer 3 since you have of the 3750 and the ASA5520. If you start to see overflow errors, you should consider using the layer 2 switch.

    -Tom
    Please mark replied messages useful

Maybe you are looking for

  • IMessage/synchronization message

    Not all of the messages that I receive on my iPhone are shown on my MacBook Pro or iPad Mini. How is the setting on my MacBook, iPad Mini and iPhone, so all iMessages/messages appear on all three of my devices?

  • I can't delete an addon

    Hello.Currently, I installed IMVU.And with it, I got an IMVU toolbar. Which I did not.And now I can not remove it, becuse the toolbar is not avalibale for 6.0.1 but yet I have the toolbar.And I won't be there. I tried everything I can to remove it. B

  • Return the focus to the main window of VI

    In fact, the scenario is a little more complicated than what is described. There is a main VI has a user interface that uses a Structure of the event to capture / process the events of the operator.  This same main VI also called live dynamic.  One o

  • BlackBerry Smartphones Blackberry curve 8520 shows the duration of the call during a call

    I was wondering if someone could help me, since a few days my screen every time I do a call is all blue, he does not see the duration of the call or the name which I'll call or called me while I'm in the call! When someone calls me it shows the name,

  • Installation of Windows Server 2008R2 on Poweredge R320 fails

    Hello It is not possible to install W2008 server. The Windows Installer process request a CD/DVD driver. We have no CD driver and we did not found a DVD driver on the support sites. Any ideas? Thank you for the help Stephan


HashFlare