Confirming the correct use of different across columns.

Hello

I have a table which consists of 6 child keys to other tables. I want each line to have a unique combination of values. To check what I have trained the following query.

SELECT DISTINCT (col_1), (col_2), (col_3), (col_4), (col_5), (col_6) FROM tableName

This is the correct syntax for finding unique combinations, it seems to return the right answer for me.

Now, I would like to know if there is no recording involved so that I can remove them, I was thinking about using an outer join to do this, but the only problem is that I have to enter the primary key of the table that then automatically makes a unique combination.

Someone would have some ideas.

Thank you
Ben

Benton says:
SELECT DISTINCT (col_1), (col_2), (col_3), (col_4), (col_5), (col_6) FROM tableName

This is the correct syntax for finding unique combinations, it seems to return the right answer for me.

A more common way to express it in Oracle, would be to leave out the parentheses:

SELECT DISTINCT col_1, col_2, col_3, col_4, col_5, col_6 FROM tableName

To find the combinations of keys that have several occurrences, you could do this:

SELECT col_1, col_2, col_3, col_4, col_5, col_6,COUNT(*)
FROM tableName
GROUP BY col_1, col_2, col_3, col_4, col_5, col_6
HAVING count(*) > 1

Tags: Database

Similar Questions

  • the printer uses a different computer. no other computer help...

    I use an HP laptop.  Just upgraded to windows 8.1.  Now, I get this message "another computer using the printer" I have a PIXMA MG5420.  I'm connected wireless.  Help, please.

    Hi traveltwo,

    Reinstall the printer drivers on your computer can solve the problem that you are experiencing.  Before you reinstall, restart your computer and the printer.  Once restarted, please click here to access the drivers and software page for the PIXMA MG5420.  Once the initial download to your model page, follow these steps:

    1. check that the operating system detected in the "OPERATING SYSTEM" drop is correct and if this isn't the case, please click on the drop down menu to select your operating system.

    2. then, click the red arrow next to the "DRIVERS" section and click on the MINI MASTER CONFIGURATION file. When you do, a red DOWNLOAD button will appear. Please click the box below the button DOWNLOAD, and then click DOWNLOAD to start the download. The time for the download process can vary depending on the speed of your Internet connection and the size of the file being downloaded.

    Once you have downloaded the INSTALLATION of MINI MASTER file, please double-click it to reinstall the drivers on your computer.

    I hope this helps!

    It has not responded to your question or problem? Please call or write to us at one of the methods on the page contact us for further assistance.

  • HP Elitebook 8560w: upgrade my ram and the correct use of slots

    Hello - my first post!

    I just bought HP 8560w refurbished seller.  It has a quad core processor and four ram slots.  I can post the SN and product number if it helps with my request.

    I want to max out my ram without disturbing the keyboard.  I currently have 4 x 4 ram installed so that four locations are used.  My machine will support a maximum of 32 of ram.

    Here is the query - I can remove the 2 ram sticks of the slots I can easily see when I remove the back (I guess these are slots 3 & 4) and replace them with 2 sticks 8 ram each?

    It would give me a total of 24 ram - 2 x 4 under the keyboard (slots 1 & 2) and 2 x 8 in two other passers-by.

    This upgrade would be OK and be recognized by the system?

    Thank you, Russ.

    Hi, Russ:

    It seems that you can according to the maintenance manual.

    http://h20628.www2.HP.com/km-ext/kmcsdirect/emr_na-c03424153-1.PDF

    He says that one of the compartment of the expansion memory slot should be filled with a chip to add a slot 2.

    It also says the same thing about the locations of primary memory under the KB.

    See Chapter 4, page 51.

  • Question about the correct use of the WM_CONCAT

    Hello

    I am trying to accomplish the following:

    from this
         ENAME
         ----------
         ADAMS
         ALLEN
         BLAKE
    ...
    and ends on this
         OLD_NAME   NEW_NAME
         ---------- --------
         ADAMS      AADMS
         ALLEN      AELLN
         BLAKE      ABEKL
    ...
    Basically, alphabetically sort the characters within each name. I have an intermediate step that seems promising
    select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
      from emp e,
           (select rownum pos from emp) iter
     where iter.pos <= length(e.ename)
     order by e.ename, substr(e.ename, iter.pos, 1);
    Yields above
    OLDNAME    NEWCHARPOS
    ---------- --------------------
    ADAMS      A
    ADAMS      A
    ADAMS      D
    ADAMS      M
    ADAMS      S
    ALLEN      A
    ALLEN      E
    ALLEN      L
    ALLEN      L
    ALLEN      N
    BLAKE      A
    BLAKE      B
    BLAKE      E
    BLAKE      K
    BLAKE      L
    ...
    the characters are in the right sequence, I thought that all I had to do was to use WM_CONCAT (and replace the comma it inserts with an empty string) and I would like to make. I thought it would do: (replacement of commas left out for clarity)
    select oldname,
           wm_concat(newcharpos) newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
           )
      group by oldname;
    but the sequence of the newcharpos is messed up in the process and, rather than the expected result, I get this:
    OLDNAME    NEWNAME
    ---------- --------------------
    ADAMS      A,S,M,D,A
    ALLEN      A,N,L,L,E
    BLAKE      A,L,K,E,B
    ...
    My question is, how to structure the last query so that the order of character as calculated in the inner query stays?

    Thank you for your help,

    John.

    Or

    SQL> select   oldname,
           wm_concat(newcharpos) keep (dense_rank last order by null)  newname
      from (
            select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos
              from emp e,
                   (select rownum pos from emp) iter
             where iter.pos <= length(e.ename)
             order by e.ename, substr(e.ename, iter.pos, 1)
           )
      group by oldname
    /
    OLDNAME    NEWNAME
    ---------- ------------------------------
    ADAMS      A,A,D,M,S
    ALLEN      A,E,L,L,N
    BLAKE      A,B,E,K,L
    CLARK      A,C,K,L,R
    FORD       D,F,O,R
    JAMES      A,E,J,M,S
    JONES      E,J,N,O,S
    KING       G,I,K,N
    MARTIN     A,I,M,N,R,T
    MILLER     E,I,L,L,M,R
    SCOTT      C,O,S,T,T
    SMITH      H,I,M,S,T
    TURNER     E,N,R,R,T,U
    WARD       A,D,R,W                       
    
    14 rows selected.
    

    Or (11 GR 2)

    SQL> select ename oldname, column_value newname
      from emp,
           xmltable(('string-join(for $i in (' || rtrim(regexp_replace(ename, '(.)', '"\1",'),',') || ') order by $i return $i, "")'))
    /
    OLDNAME    NEWNAME
    ---------- ------------------------------
    SMITH      HIMST
    ALLEN      AELLN
    WARD       ADRW
    JONES      EJNOS
    MARTIN     AIMNRT
    BLAKE      ABEKL
    CLARK      ACKLR
    SCOTT      COSTT
    KING       GIKN
    TURNER     ENRRTU
    ADAMS      AADMS
    JAMES      AEJMS
    FORD       DFOR
    MILLER     EILLMR                        
    
    14 rows selected.
    
  • Creating a popup message confirming the sending of form ONLY if all fields are correctly entered

    I use and learn Dreamweaver 2015.  I created a few forms to a Web site for a project, and while I got the correct validation for some fields (name required in the field name) settings, a valid email address for field email, etc, I can't find a way to bring up a window confirming the correct presentation if the fields have been correctly entered on the form.  If the fields are free of errors, I want to say something like "thanks for your message.  You should hear from us shortly. "I am limited to HTML5 and javascript.

    Thanks in advance!

  • Dashboard calls between 2 different date columns

    Hi all

    I am creating a dashboard command prompt that will allow users to filter the report from 2 different date columns. We have an opening date column and a column of closing date. I want to allow users to choose an opening date and then a closing date that is at a later date. How could I go to set it up?

    Thank you in advance!

    I received your question, but I was not sure of your ability to create guest

    You will use 2 open and closed dates in the command prompt and set the variables in the presentation. In the report for this 1 date column use <= and="">= instead of operator.

  • Correct use of snapshots

    Hello

    I would like to have comments about the correct way to use snapshots.

    Currently, I have a server ESXi 3.5 with 4 virtual machines.

    I use snapshots as follows:

    -J' still have 1 snapshot taken for each virtual computer

    -J' have regularly (before the size of the snapshot becomes too large) remove the snapshot and just after, take a new snapshot for each virtual machine

    -I will soon be able to make a backup of my virtual machines, but I don't now

    I recently started to monitor the size of my virtual machines, and they become several GB in just a few days.

    I wonder if it is efficient to always have a snapshot on each virtual machine.

    I'm starting to think maybe this snapshot should be taken just before to make a change on the server (installation of the software or other) to return to the State that we had before the operation, in the case where he's going poorly, then remove the snapshot after we have confirmed the operation went well, but should not exist at all times.

    Your comments are welcome! Thank you!

    Yann

    The snapshots are NOT backup anyway. If you use instant as replacement of backup then

    (1) you lose a costly storage space

    (2) that you have less reliable

    (3) you generate disk load high commit when snapshots

    What is the correct use of the snasphots:

    (1) you need to install a patch on your virtual machine

    (2) take the snapshot

    (3) install the patch

    (4) monitor behaviour of the system in case of patch broke something for awhile

    (5) commit instant if everything is ok, or go back to the snapshot if something bad happened.

    ---

    MCSA, MCTS, VCP, VMware vExpert 2009

    http://blog.vadmin.ru

  • Correct use of setControllerFactory in FXMLLoader?

    Hello

    I'm trying to load a node FXML using my own controller using JavaFX 2.1 included in the JDK 7u4.
    All discussions point to the setControllerFactory method, but when I try to apply the code below, the plant is never called leaving the node without the controller.
    (the FXML does not set the fx:controller).

    I've probably missed the correct use, but I can't understand. A tip?
     private Node loadNodeWithCtrl(final Object instance, String fxmlPath, ResourceBundle rb) {
            URL url = this.getClass().getResource(fxmlPath);
            FXMLLoader fxmlLoader = new FXMLLoader(url, rb);
            fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() {
    
                @Override
                public Object call(Class<?> paramClass) {
                    // Never reached <<<<<<<<<<<<<<<<<<<<<<< 
                    Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Using provided controller");
                    return instance;
                }
            });
       
            try {
                Node node = (Node) fxmlLoader.load();
                return node;
            } catch (IOException ex) {
                Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
            }
            return null;
        }
    Concerning

    Jean-Michel

    This is the correct behavior. Controller factories provide a way for an application to customize the construction of controllers specified via the fx:controller attribute. If you do not use fx:controller, then the controller factory will not be called.

  • When you try to upgrade using the Windows Anytime Upgrade feature, it tells me to use a different key.

    Upgrade in Windows 7 Home Premium to professional

    I have Windows 7 Home Premium (OEM Version) installed in Australia and bought a Windows 7 Professional upgrade key in the United States. When you try to upgrade using the Windows Anytime Upgrade feature, it tells me to use a different key, yet my upgrade pack tells me to use the Windows Anytime Upgrade feature! I bought the upgrade from a reputable store in San Francisco. Any ideas why it does not work?

    What is a retail upgrade or full version or an Express upgrade?

    If its OEM license, it will not work.

    If at any time the upgrade fails, Windows Anytime Upgrade Fail:

    Shut down and restart your computer.

    Make sure that the Windows updates have been installed.

    Download the hotfix that contains a tool called CheckSUR, this tool will look at the package and the maintenance of records and difficulty any data corrupted, the tool is listed under kb947821 he can be found at the following link http://support.microsoft.com/?kbid=947821

    If Anytime Upgrade still does not work, turn off the user account control:

    1. go in user accounts in Control Panel

    2 change user account control settings

    3. pull the slider to the level as low as possible

    4. restart the PC

    5. pass by the "Anytime Upgrade" as usual

    Try the following:

    1 disable any security software before attempting to upgrade

    2. make sure that your computer is updated (devices and applications)

    3. disconnect all external devices before installing.

    4. check your hard disk for errors:

    Click Start

    Type: CMD, according to the results, right-click CMD

    Click on "Run as Administrator"

    At the command prompt, type: chkdsk /f /r

    When you restart your system, your computer will be scanned for errors and will try to correct them.

    1. click on start, type msconfig in the search box and press ENTER.

    User account control permission

    If you are prompted for an administrator password or a confirmation, type the password, or click on continue.

    2. in the general tab, click Selective startup.

    3. under Selective startup, clear the check box load startup items.

    4. click on the Services tab, select the hide all Microsoft Services check box, and then click Disable all.

    5. click on OK.

    6. When you are prompted, click on restart.

    7. after the computer starts, check if the problem is resolved.

    Also run the Windows 7 Upgrade Advisor:

    http://www.Microsoft.com/Windows/Windows-7/Upgrade-Advisor.aspx

    Who should I contact if I have problems installing and / or activation of my product key card?

    Please contact to the: www.windows7.com/getkeysupport.

    If all above fails them, install Windows 7 Service Pack 1, and then try the Express Upgrade:

    Learn how to install Windows 7 Service Pack 1 (SP1)
    http://Windows.Microsoft.com/en-us/Windows7/learn-how-to-install-Windows-7-Service-Pack-1-SP1

    If your key is not valid and you will need to change the keys, you may need to Open regedit and remove first the ProductKey value in the following registry key:
     
    HKCU\Software\Microsoft\Windows\CurrentVersion\WindowsAnytimeUpgrade

  • How better to insert a subarray (line) in a 2D array to the correct index which is based on the value of the first column

    Hello

    I would like to insert a subarray (line) in a 2D to the correct index table. The position is to say the index value depends on the value of the first column of the table 2d.

    As an examlple my 2d array would look like this

    230 50 215 255

    300 60 270 330

    360 20 350 370

    And I would like to insert another line (subarray) with the following values

    320 40 300 340

    This new line should be placed between the second and third rows (this is based on the first column only).

    I tried the threshold 1 d function table by taking an 1Dsub array of my 2d array (first column), then using the first of the new line (320) as the threshold. It sort of work, but it does not work when I start the table (IE there is only 1 row) and it seems to not work properly on other occasions (as explained in the help of Labview).

    Hopefully the explanation is clear enough for any suggestion. Thanks in advance for the help!

    JTRI wrote:

    The idea is I have start with a new table and add these lines in the right order every time that the user sets the values Jack

    Ahh, so try this.

    This will also work with an empty array.

    You want to do with this function it is a Subvi.

    Make the entries 'table' and 'subarray"on the connector, then 'new array' output.

    You can then put this Subvi in a loop with a registry to shift and it will help to add new lines in a sorted order, when they are added.

    That is what you were aiming for?

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • update to column values (false) in a copy of the same table with the correct values

    Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.

    My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:


    Update mnt.workorders
    Set approvalstat = (select b.approvalstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)
    where exists (select *)
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)

    It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.

    Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:

    Update (select a.comappstat, b.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi - this is a PK column
    and a.comappstat! = b.comappstat)
    Set b.comappstat = a.comappstat

    Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:

    Update mnt.workorders_copy
    Set comappstat = (select distinct)
    a.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi
    and a.comappstat! = b.comappstat)
    where a.comappstat! = b.comappstat
    and a.workordersoi = b.workordersoi

    The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :

    ERROR on line 8:
    ORA-00904: "B". "" WORKORDERSOI ": invalid identifier

    First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)

    Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?

    I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.

    Thank you

    Hello

    First of all, after post 79, you need to know how to format your code.

    Your last request reads as follows:

    UPDATE
      mnt.workorders_copy
    SET
      comappstat =
      (
        SELECT DISTINCT
          a.comappstat
        FROM
          mnt.workorders a
        , mnt.workorders_copy b
        WHERE
          a.workordersoi    = b.workordersoi
          AND a.comappstat != b.comappstat
      )
    WHERE
      a.comappstat      != b.comappstat
      AND a.workordersoi = b.workordersoi
    

    This will not work for several reasons:
    The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
    There is no link between the mnt.workorders_copy and the the update and the request of void.

    If you do this you should have something like this:

    UPDATE
      mnt.workorders     A      -- THIS IS THE TABLE YOU WANT TO UPDATE
    SET
      A.comappstat =
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B   -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    WHERE
      EXISTS
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    

    Speed is not so good that you run the query to sub for each row in mnt.workorders
    Note it is condition in where. You need other wise, you will update the unchanged to null values.

    I wouold do it like this:

    UPDATE
      (
        SELECT
          A.workordersoi
          ,A.comappstat
          ,B.comappstat           comappstat_OLD
    
        FROM
          mnt.workorders        A      -- THIS IS THE TABLE YOU WANT TO UPDATE
          ,mnt.workorders_copy  B      -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
    
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      ) C
    
    SET
      C.comappstat = comappstat_OLD
    ;
    

    This way you can test the subquery first and know exectly what will be updated.
    This was not a sub query that is executed for each line preformance should be better.

    Kind regards

    Peter

  • What is the correct syntax for the use of a variable in an ad-hoc query?

    Hi all

    I'm a casual user of the DB and right now need to update the records about 1000 + so that a certain column gets a unique value.

    So I thought I'd use a variable for this.

    Then, I built this type of SQL statement for only a small subset of records:
    ----------
    variable number recNumber;
    exec: recNumber: = 1;
    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD + recNumber
    WHERE COL_TO_BE_UPD IN ('VAL_A', 'VAL_B');
    ----------

    I get invalid SQL statement error when you try to run above (except for the guest who asks for a value I want to omit).

    In any case, I also tried this one:
    ----------
    CREATE SEQUENCE seqCounter;
    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD + seqCounter.NEXTVAL
    WHERE COL_TO_BE_UPD IN ('VAL_A', 'VAL_B');
    ----------

    Of it, I got the error ORA-01722: invalid number... I guess it's because seqCounter is of type number and the COL_TO_BE_UPD is of type character... (?)

    Then I want to ask is what is the correct way to define and use a counter variable type to add a number at the end of a string?

    Also another question I would ask is that are variables that are used in queries ad hoc, also called "bind variables"?

    Thank you muchly

    If you want to add a unique number to a column, then it would be:

    UPDATE TABLE_TO_BE_UPD
    SET COL_TO_BE_UPD = COL_TO_BE_UPD ||to_char(rownum)
    WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
    
  • Columns with the same name but different data or precision length.

    DB version: 10 gr 2

    In a diagram, I need to find all of the columns with the same name but different or precision data length (if the column is of type number). I know I have to use the USER_TAB_COLS view for this. But I need to find a logic to compare the names of columns and its lengths.

    something like

    select t1.table_name
         , t1.column_name
         , t1.data_type
         , t1.data_length
         , t2.table_name
         , t2.column_name
         , t2.data_type
         , t2.data_length
      from user_tab_columns t1
         , user_tab_columns t2
     where t1.table_name != t2.table_name
       and t1.column_name = t2.column_name
       and t1.data_type = t2.data_type
       and t1.data_length != t2.data_length
    

    ... could be a starting point.

  • I have a chase bank credit card that I have good ranking and what number do I call to talk to I tunes because he says, use a different card, it's the map I was buy everything what I tunes. Is it because I have challenged their load m

    I have a chase bank credit card that I have good ranking and what number do I call to talk to I tunes because he says, use a different card, it's the map I was buy everything what I tunes. Is it because I thought them charge me twi

    Can I have it please the number on I tunes support whether please or have them call me at * Leonardo B *.

    < personal information under the direction of the host >

Maybe you are looking for