compare the 4 fields in a table

Hi, today my brain pains, can someone please tell me how to compare 4 fields in a table to see if they are all equal?
create table dm_test (n_1 number,
n_2 number,
n_3 number,
n_4 number);
INSERT INTO dm_test
     (n_1,
      n_2,
      n_3,
      n_4)
VALUES
     (1,
      1,
      1,
      1);
     
 INSERT INTO dm_test
     (n_1,
      n_2,
      n_3,
      n_4)
VALUES
     (3,
      2,
      2,
      2);
         
  INSERT INTO dm_test
     (n_1,
      n_2,
      n_3,
      n_4)
VALUES
     (0,
      0,
      0,
      3);
        
The result of my query must return only
first row
1 1 1 1

Thanks people...

Maybe something like that?

SQL> SELECT  *
  2  FROM    dm_test
  3  WHERE   n_1 = n_2
  4  AND     n_2 = n_3
  5  AND     n_3 = n_4
  6  /

                 N_1                  N_2                  N_3                  N_4
-------------------- -------------------- -------------------- --------------------
                   1                    1                    1                    1

It won't however if you're concerned about NULL values. Do you want a row to return if they are NULL?

EDIT:

The version that supports the NULL:

SQL> INSERT INTO dm_test VALUES(NULL,NULL,NULL,NULL);

1 row created.

SQL> SET NULL '(null)'

SQL> SELECT  *
  2  FROM    dm_test
  3  WHERE   NVL(n_1,-1) = NVL(n_2,-1)
  4  AND     NVL(n_2,-1) = NVL(n_3,-1)
  5  AND     NVL(n_3,-1) = NVL(n_4,-1)
  6  /

                 N_1                  N_2                  N_3                  N_4
-------------------- -------------------- -------------------- --------------------
                   1                    1                    1                    1
(null)               (null)               (null)               (null)

Edited by: Centinul May 14, 2010 07:07

Tags: Database

Similar Questions

  • Disqualification: Compare the value list in another Table

    I'm relatively new to the Disqualification.

    I use the 11.1.1.7 version.

    I have 2 tables Oracle.  Table1.FieldA does not have a foreign key constraint (but should be) at Table2.FieldB.

    I created a snapshot for Table1 that includes FieldA.

    I created another cliché to Table2 which includes FieldB.

    I am trying to compare the Table1.FieldA with Table2.FieldB value to make sure that there is.

    I can think of a few processors that I could, but they seem to compare a value with another value in the same snapshot (table).

    Any advice would be helpful.


    Thank you.

    Ray

    Hello

    Use the search check if you want to just check between the tables. According to the reference database, you need create a list of choices on the table (can be either staged as you, or just a list of external choice provided the lookup columns are indexed). Use Lookup and return if you want to import data in the other table in your process. You can control if you want a 1:1 or from a 1:M relationship, and if you go back several records, you can use split chronogram: table with all the paintings of entry to create an intermediate join process.

    Mike

  • It is possible to compare the contact fields based on the value of data updated?

    Hi all -

    I would like to run a filter and compare my contact fields if the value in a field has been updated or changed.

    for example if the data in the "first name" value changes to be empty to have a value, which would respect the requirement.  Also if "phone number" 123-456-7890 to 999-000-0000 that would also meet the requirement.

    Did anyone done this before?  Any ideas of how to implement?

    Any contribution is appreciated.  Thank you!

    If that's what you're talking about, there is no trace of audit in Eloqua.

    It will be great if Oracle can verify the critical fields.

    The solution is to create to the top of the field in another area, so when it changes, you can compare the values.

    Good luck

  • Canvas campaign: filters common vs compare the Contact fields

    HI -.

    Is there a difference between using one or several Contact fields compare elements vs using a shared filter?

    In my campaign, I need to check if one of the three fields is equal to something specific (and therefore remove them from the campaign).  I couldn't achieve exactly the same results if I used a shared filter that sought the same criteria?

    Thank you

    Abe

    1. the shared filter evaluates when someone passes through this point of decision.  It is different from that of a Segment in which a Segment is your first point of qualification for a campaign (so why someone "stays in the segment").  They actually stay in the segment so that they did not leave the campaign yet.  If the segment is more permissive, your filter shared between them, so that hardly leave the campaign according to your rule.

    2. I saw your other post on the date field.  You're right... when I try in the Web I get an error as well.  Definitely a bug in the interface user, as you can do in a segment.  I would say for now you use the shared empty contact filter and log a ticket with Support for the bug in the user interface.

  • By comparing the dynamic fields of objects using equals and hashCode methods

    To compare the different objects of the same class with their content as jobTitleId, classificationId, deptId & classificationId had to be done and do a few steps later, using Set and the map. I was able to do it by simple substitution of equals and hashCode methods of the object class and was able to read the information (as in the map below).

    Map < LocationData, list < LocationData > >

    The following is the class I used (its been shown you so that it can be called for my problem statement):

    Class LocationData

    package com.astreait.bulkloader;

    public class LocationData {}

    String locId, deptId, jobTitleId, classificationId;

    @Override

    public boolean equals (Object obj) {}

    LocationData ld = (LocationData) obj;

    return this.deptId.equals (ld.deptId) & & this.jobTitleId.equals (ld.jobTitleId) & & this.classificationId.equals (ld.classificationId) & &

    this.locId.equals (ld.locId);

    }

    @Override

    public int hashCode() {}

    return deptId.hashCode () + jobTitleId.hashCode () + classificationId.hashCode () + locId.hashCode ();

    }

    }

    Problem:

    I am already known to which all the fields of this object, I need to make the comparison.

    IE I have to use the variables named classificationId, deptId, jobTitleId & locId etc.

    Need:

    I need to customize this logic such as names (classificationId, deptId, jobTitleId & locId etc.) fields can be learned, dynamically, as well as their values. So, as far as I understand, I've made use of 2 classes (TableClass and ColWithData), such as the list of the ColWithData is there in the TableClass object.

    I think what will happen if I substitute the same two methods "equals() and hashCode();"

    as the same thing is possible.

    TableClass class #1

    Class TableClass {}

    The list < ColWithData > cwdList;

    @Override

    public boolean equals (Object obj) {}

    Return Boolean = false;

    I need to have the logic must be set such that

    all dynamic fields can be compared

    return return;

    }

    @Override

    public int hashCode() {}

    Return int = 0;

    I need to have the logic must be set such that

    All dynamic fields for their individual codes can be found

    return return;

    }

    }

    ColWithData class #2

    Class ColWithData {}

    Pass the string; Here, the jobTitleId, classificationId, deptId, locId or any other information fields more may come.

    String data; The corresponding data or value for each jobTitleId, classificationId, deptId, locId or any other more fields.

    }

    Please let me know if I'm the procedure in the right direction or should I do a different approach. If it is allowed to use the current approach then what should be done to equals and hashCode methods?

    Finally, I need to make the map as: (is not worried how I give you, but may be considered my goal sought this logic)

    Map < TableClass, list < TableClass > > finalMap;

    I'm sorry for that. Although the problem is resolved, on my side.

  • validate/compare the 2 fields amount

    Hi all

    I am using oracle 10 G on windows forms.

    I need help on how to validate the amounts 2 fields.
    I compare 2 amounts fields, if the amounts are equal, then all is good. However, if the amounts are $ 5, which is very good but I would like to display a warning to the user. And if the amounts are more than $ 5, then display a different message and do not allow additional processing.

    Thanks for your help in advance,

    Hello

    Suppose you have a datablock named YOUR_BLOCK and the elements named S1 and S2.
    You need to create an alert, it's easy, go to the object navigator palette, search alerts, and then click on the button create, give to alert a name, we named our alert CFG_ASK.

    Try this in a trigger or a button, I suggest you to use when validating the trigger...

    IF :YOUR_BLOCK.S1 IS NOT NULL AND :YOUR_BLOCK.S2 IS NOT NULL THEN
    
    IF :YOUR_BLOCK.S1 <> :YOUR_BLOCK.S2 THEN
    
         IF ABS(:YOUR_BLOCK.S1 - :YOUR_BLOCK.S2) <= 5 THEN
          ALERT_CALL('CFG_ASK','ALERT','THERE IS A LITTLE DIFFERENCE');
         ELSE
              ALERT_CALL('CFG_ASK','ERROR','TOO MUCH DIFFERENCE!');
              RAISE FORM_TRIGGER_FAILURE;
         END IF;
    
    END IF;
    
    END IF;
    

    Alert_call code (program unit):

    PROCEDURE alert_call(alert_name varchar2, title_name varchar2, msg_name varchar2) IS
    
    AL_ID ALERT;
    AL_BUTTON NUMBER;
    
    BEGIN
      AL_ID := FIND_ALERT(alert_name);
      IF ID_NULL(AL_ID) THEN
           MESSAGE('There is no alert window '||alert_name); -- you must to create an alert
           RAISE FORM_TRIGGER_FAILURE;
      ELSE
           Set_Alert_Property(AL_ID, TITLE, title_name);
           Set_Alert_Property(AL_ID, ALERT_MESSAGE_TEXT, msg_name);
        AL_BUTTON := SHOW_ALERT(AL_ID);
        IF AL_BUTTON = ALERT_BUTTON1 THEN
             NULL;
        END IF;
      END IF;
    END;
    

    It will be useful.

    Points to keep in mind.

  • AddRow on enter on the last field in a table

    Hello

    4.2.6.00.03 on 11.2 db APEX


    I am trying to find a way to add a new line when pressing enter in the last field in tabular form. The user does not want to press the new button to add a line every time, but I want to just press on enter the last field, indicating that a new line should be added.

    Anywbody is an easy trick for this (probably the JS that is not my specialty )?


    Concerning

    Bottom


    Hi there,

    Try the following steps below

    Create a dynamic action:

    Event: Down key

    * Type selection: dom

    * DOM object: window

    Condition: Expression of Javascript

    window.event.keyCode is 13;

    Real action

    Action: Run Javascript code

    under settings-> code->::AddRow();

    Check out this old thread for more details: Add addRow tabular without button

    Kind regards

    Jitendra

  • By comparing the inputtext fields

    Hello
    I have a simple question. I'm usgin Jdev 11.1.2.2.0. My use case:

    I have a VO with 3 fields (username, question and answer).
    When the user enters the answer, I need to check in the database for the particular ANS if it is appropriate, the user be able to.
    The steps I did:
    (1) created read only VO.
    (2) developed a method in the bean, which will be the username, answer.
    (3) callin the method in the module of the application.
    (4) but I always "result: error".

    Bean code:

    public String answerTabout (ValueChangeEvent valueChangeEvent) {}
    String resultstr = "error";
    User String = (String) username.getValue ();
    Years = (String) checkAns.getValue ();
    System.out.println ("Calling");
    Links DCBindingContainer = ((DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ());
    Method of the class OperationBinding = bindings.getOperationBinding ("checkUser");
    Map params = method.getParamsMap ();
    params.put ('years', years);
    params.put ("user", user);

    System.out.println ("Done");

    Object result = method.execute ();
    {if (!) Method.GetErrors (). IsEmpty())}
    ResultStr = "success";
    System.out.println ("result" + resultstr);

    }
    System.out.println ("returnStr =" + resultstr);
    Return resultstr;
    }


    Code of the AOS:

    ' Public Sub checkUser (String years, String user)
    {
    AnswerVOImpl vo = (AnswerVOImpl) getAnswer1 ();

    System.out.println ("frm applcaitoon");
    System.out.println (years + "" + user);
    System.out.println (VO);
    vo.setNamedWhereClauseParam("check_user",user);
    vo.executeQuery ();
    int rowCount = vo.getEstimatedRangePageCount ();
    int count = vo.getRowCount ();

    System.out.println ("ROWCOUNT =" + RowCount);
    {if(ROWCOUNT==0)}
    System.out.println ("no match");

    }


    log file:
    the call
    fact
    FRM applcaitoon
    Jose ispl\dmptest
    com.laurus.model.viewobject.readonly.AnswerVOImpl@188834e
    number of lines = 1
    returnStr = error

    What's not in my code? Or is there another method better do?

    Your check condition after execution of the binding of the method is the wrong way autour:

    if(!method.getErrors().isEmpty()) {
    resultstr = "succes";
    System.out.println("result " + resultstr);
    }
    

    should be

    if(!method.getErrors().isEmpty()) {
    // you get here only if the method returns an error
    System.out.println("result " + resultstr);
    return;
    }
    
    int count = (int)method.getResult();
    if (count > 0)
        resultstr = "succes";
    
    System.out.println("result " + resultstr);
    return resultstr;
    

    Next, you need to return something from the AM method. Otherwise, you cannot know if the answer matches.

    // return no of rows found. If count == 0 no match found
    public int checkUser(String ans, String user )
    {
    AnswerVOImpl vo = (AnswerVOImpl)getAnswer1();
    System.out.println("frm applcaitoon");
    System.out.println(ans + " " + user);
    System.out.println(vo);
    vo.setNamedWhereClauseParam("check_user",user);
    vo.executeQuery();
    int rowCount=vo.getEstimatedRangePageCount();
    System.out.println("rowCount="+rowCount);
    if(rowCount==0) {
    System.out.println("not matched");
    
    return rowCount;
    }
    

    You should check the AM method. It looks like, it does not check the answer, but only the user.

    Timo

  • grouping to do by comparing the 2 lines in a table

    Hello
    I use oracle 10g.
    I have a table with 3 columns
    ID-origin - destination
    1---------N1-----------N3
    2---------N2-----------N4
    3---------N2-----------N4
    4---------N1-----------N3
    5---------N2-----------N6
    6---------N1-----------N3
    7---------N2-----------N6

    If there are common id contains the same origin and destination even then group them as

    ID-origin - destination
    1 N1 - N3 - G1
    2 N2 - N4 - G2
    3 N2 - N4 - G2
    4 N1 - N3 - G1
    5 N2 - N6 - G3
    6 N1 - N3 - G1
    7 N2 - N6 - G3

    Please help me

    Thank you
    Sandeep
    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 1 as id, 'N1' as origin, 'N3' as destination from dual union all
      2             select 2, 'N2','N4' from dual union all
      3             select 3, 'N2','N4' from dual union all
      4             select 4, 'N1','N3' from dual union all
      5             select 5, 'N2','N6' from dual union all
      6             select 6, 'N1','N3' from dual union all
      7             select 7, 'N2','N6' from dual)
      8  --
      9  --
     10  --
     11  select id, origin, destination
     12        ,dense_rank() over (partition by 1 order by origin, destination) rnk
     13* from t
    SQL> /
    
            ID OR DE        RNK
    ---------- -- -- ----------
             1 N1 N3          1
             4 N1 N3          1
             6 N1 N3          1
             3 N2 N4          2
             2 N2 N4          2
             7 N2 N6          3
             5 N2 N6          3
    
    7 rows selected.
    
  • Get the unwanted fields - inappropriate length - Table

    Hello Experts,

    SELECT     COUNT ( * ) FROM mtl_system_items_b; 
    -> 664072 records
     
    In fact, the value of the segment1 should be 9. But there a few unwanted characters and a few extra characters.

    If I use the following query to get all the error values of the segment.

    Please confirm is this rite of query?
    SELECT     segment1
    FROM          mtl_system_items_b
    WHERE      LENGTH (segment1)  != 9;
     
    If there is no other better query thanks to...

    Thank you...

    In this case, the! = or <> must be correct. that is how you formed the query.

    Kind regards
    P.

  • limits the maximum length of the text field in a table

    How can I do this with standard javascript (not jquery, no apexlib)

    Hello

    Will the column attributes and the attributes of the element instead

    onfocus="this.maxLength=10"
    

    Works at least with Firefox

    BR, Jari

  • Compare the content of two equal nested tables

    I'm working on a black box test where I compare the contents of two structurally equal tables before and after executing a script of some. My two tables, MDQ_OLD and MDQ_NEW, are filled with the data in two separate operations.

    The two tables, I'll compare are nested, as you can see in the CREATE TABLE scripts below.

    I tried to use the less-operator sign, but without success.

    I also tried to select data in a type that is % ROWTYPE to my nested tables, but it does not work as well (see the below script in this post).

    Can you please help me on this problem on how to compare the content of two nested tables?

    Run the scripts below to reproduce the problem and be sure to update this post if more information is required.

    -The scripts below-

    Select * from version of v$.

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

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    -First of all, I create my types

    CREATE OR REPLACE TYPE FORCE AS OBJECT MDQ_DETAIL (NUMBER OF MDQ_DETAIL_ID, MDQ_DETAIL_DESC VARCHAR2 (100));

    CREATE OR REPLACE TYPE T_MDQ_DETAIL AS TABLE MDQ_DETAIL;

    -Note that this type contains the table T_MDQ_DETAIL type:

    CREATE OR REPLACE TYPE MDQ_PARENT FORCE AS OBJECT (NUMBER MDQ_ID, MDQ_DETAILS T_MDQ_DETAIL);

    - Then I create two equal nested tables

    CREATE THE NESTED TABLE AS MDQ_PR_OLD STORE MDQ_DETAILS MDQ_PARENT MDQ_OLD TABLE.

    CREATE THE NESTED TABLE AS MDQ_PR_NEW STORE MDQ_DETAILS MDQ_PARENT MDQ_NEW TABLE.

    -Insert test data in the nested tables

    Insert into MDQ_OLD (MDQ_ID, MDQ_DETAILS) Values (1, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    Insert into MDQ_NEW (MDQ_ID, MDQ_DETAILS) Values (2, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    -Try to use the negative operator to compare the contents of the trailer of the nested tables, but it gives this error:

    -ORA-00932: inconsistent data types: expected - got DISPATCH. T_MDQ_DETAIL

    Select * from MDQ_NEW

    less

    Select * from MDQ_OLD;

    -Try to select in a ROWTYPE, but it fails

    declare

    myTypeOld MDQ_OLD % ROWTYPE;

    myTypeNew MDQ_New % ROWTYPE;

    myTypeDiff MDQ_New % ROWTYPE;

    Start

    -Select gives: PLS-00497: do not mix between row and several rows (in BULK) list

    Select * bulk collect into mdq_old myTypeOld;

    Select * bulk collect into mdq_new myTypeNew;

    -Need a 'compare the function of membership card' on the types of multiset except to work, but as far as I

    -I'm not able to bulk collect into myTypeOld or myTypeNew, this won't help out me.

    myTypeDiff: = multiset myTypeOld except myTypeNew.

    end;

    -Cleaning:

    drop table MDQ_OLD;

    drop table MDQ_NEW;

    type of projection MDQ_PARENT;

    type of projection T_MDQ_DETAIL;

    type of projection MDQ_DETAIL;

    > queries you provided intercepts not who.

    You asked how to compare the content of nested tables.

    I knew that you didn't ask for what you actually want, that's why I asked you to specify the comparison more in detail.

    > Do you have a query that grabs this difference as well?

    SELECT o.mdq_id, od.*
    OF mdq_old o, TABLE (o.mdq_details) od
    LESS
    SELECT n.mdq_id, nd.*
    OF mdq_new n, TABLE (n.mdq_details) nd;

    > Also, if possible, do you have a sample of a statement to COLLECT LOOSE, please?

    Actually, you raise an interesting point on using % ROWTYPE, in my view, that should be. This make...

    DECLARE
    TYPE rt_mdq_new () IS RENDERING
    mdq_id NUMBER,
    mdq_details t_mdq_detail);
         
    TYPE tt_mdq_new IS TABLE OF THE rt_mdq_new;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    SELECT mdq_id, mdq_details
    LOOSE COLLECTION t_mdq_new
    OF mdq_new min.;
    END;
    /

    DECLARE
    CURSOR c_mdq_new
    IS
    SELECT mn.*
    OF mdq_new min.;
         
    TYPE tt_mdq_new IS TABLE OF c_mdq_new % ROWTYPE;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    OPEN c_mdq_new.
    Get the c_mdq_new COLLECT in BULK IN t_mdq_new;
    CLOSE C_mdq_new;
    END;
    /

  • Confirm the email address on the form field

    Is there a simple way to add a field "Confirm email address" in our forms so that people don't accidentally send forms with an incorrect email? It would be just to compare the two fields to make sure they match.

    Try this:

    http://KB.worldsecuresystems.com/598/bc_598.html#main_Adding_an_email_verification_field_t o_a_web_form

  • Compare the table and out of the common elements

    Hello

    Can you help me to compare the two tables in the attached file in VI and out the elements common to the two tables?

    Thank you

    hiNi

    There is no wire table through the False State in the structure of your business.  Use the default value if unwired is selected for this tunnel. the default value for this tunnel is an array of empty strings.  Run the wire straight through, and Bob's your father's brother.

  • How to compare the original value of table size and the changed value

    juice I took a table and then took the function of the size of the array so that it shows me the number of the elements present in it. so it'll be the original table size value. If the items in the table even changes another value, then I want to compare the original table size value and the value of table size has changed. How to compare... Please help me. you are looking for a possible solution. Thank you

    Hi stara,

    the attached picture shows the ony solution.

    It will be useful.

    Mike

Maybe you are looking for