Only insert table row with duplicates with the same information line

Hello

I have the following tables:

(Registration) CREATE TABLE

name varchar (10) NOT NULL,

country of varchar (10) NOT NULL,

Date of varchar (10) NOT NULL,

[....]

);

and the second

CREATE TABLE names

name varchar (10) NOT NULL,

country of varchar (10) NOT NULL,

Date of varchar (10) NOT NULL,

CONSTRAINT PK_names PRIMARY KEY (name, country);

I'm trying to insert in the last lines of the table in the first table (REGISTRATION), but there is an error: "constraint unique (s.%s) violated.

The insertion code I used is:

INSERT INTO name (name, country, date)

SELECT DISTINCT name, country, max (date) registration;

The table ENTRIES have similar duplicate records as (I write only the corresponding columns of the table)

NAME                         country                                        DATE

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CSA.                             Fiji 1954-09-17

ASC                              Fiji                                          1967-06-23

I want to only insert names the first registry because it is the first date on the two registers.

Thank you very much.

Hello

SELECT DISTINCT nombre_club, pais_club, max (fecha_fund_club) of INSCRIPTIONS;

will give you the error

ORA-00937: not a single group group function

So I don't see how you can run the insert statement and get the unique constraint error

I think that's what you wanted? Which should solve the unique constraint as the ORA-00937:

INSERT IN TOWN (nombre_club, pais, ano_fundacion)

SELECT nombre_club, pais_club, max (fecha_fund_club) of the Group of the INSCRIPTIONS of nombre_club and pais_club;

Kind regards

Thierry

Tags: Database

Similar Questions

  • CF8 cfquery multiple table join with the same names of columns - default

    This seems to be a defect in the CF8 cfquery object. I'm at a loss as to a solution or a good work around. With regard to the substance, this query is generated dynamically on the fly based on what is happening in it a user. This isn't the most elegent SQL but work and return all columns. The app itself is a data viewer to look at the logs. Here is an example of a query being generated.

    Select *.

    of web_trans, web_info_trans, web_res_trans

    where (web_info_trans.trans_dte > = '' 2008-12-1)

    and web_info_trans.trans_dte < '' 2008-12-2)

    and (web_info_trans.trans_dte = web_trans.trans_dte)

    and (web_info_trans.trans_num = 5060345)

    and (web_info_trans.trans_num = web_trans.trans_num)

    and (web_res_trans.trans_num = 5060345)

    and (web_res_trans.trans_num = web_trans.trans_num)

    and (web_trans.web_trans_cde = "NTUI")

    and (web_trans.web_status_cde = 'P')

    and (web_trans. TRANS_NUM < 5060347)

    order of web_trans. TRANS_NUM / / desc

    These three tables contain a similar column called ZIP_CDE. They contain different values, and when this query is executed in Microsoft Query Analyzer results are displayed correctly. Run this same query SQL with CFQUERY and the value of one of the other tables (web_trans) will eventually replace the value for the other columns called ZIP_CDE. The exact amount columns are retruned only values some how get corrupted.

    This is a defect of cf8 is a book autour or an update that resolves this problem that I may have missed?

    Thank you for the ideas.

    Thus it seems still as a default since CF is essentially where, except for the return value play. Other query tools return results correctly so for me, it turns out be CF bug at a certain level.

    Actually I'm swinging to agree with you here, but not for the same reason.  CF actually * is * get all the columns back (as you say), it just doesn't expose a way to tell the difference between a column called 'x' and an another column called 'x', because the way to access the data in columns is simple queryname [columnName] [rowNumber] (or a Variant fo this, but all the amount of variations to that or abbrev. it).  This code shows how he has all four columns of the original two queries (being a stand-in for tables, in this case):


    Q1 = queryNew("");
    Q2 = queryNew("");
       
    queryAddColumn (q1, 'id', [1,2,3,4]);
    queryAddColumn (q1, "data", ["one", "two", "three", "four"]);
    queryAddColumn (q2, 'id', [1,2,3,4]);
    queryAddColumn (q2, "data", ["tahi", "rua", "toru", "wha"]); It's Maori, in case you are interested


    SELECT *.
    Q1, q2
    WHERE q1.id = q2.id

    So CF knows there are four columns (a call getMetadata (q3) get also demonstrates this), but it does not expose a way to approach the second (or even greater) column of the same name.  This is the bug/shortfall.

    However, relying on an underlying coldfusion.sql.QueryTable method, you can rename the columns, so:

    Then you're OK.

    I would be normally reluctant to recommend doing this, because these methods change from version to version of CF, but it's your call whether this approach will help you.

    To be honest, I'm with Owain who, even in SQL one generally doesn't work with columns with the same name, an alias them qualified with a table name/alias. As the table columns from of is not returned by SQL with the result set, it must be evidence against this by folding the columns in the first place.

    Also, I wonder at the bottom of the extraction of data, you don't really know the structure, that is to say, do SELECT *.  How can you know not even that is ours as the first column, second column, etc.?  I don't think that SQL applies in fact a contract that, t - it?  (I don't know).

    What are you actually do here?

    --

    Adam

  • All the fields are filled automatically with the same information as in the field.  When deleting, all delte also fields.

    Whenever I type information in the first field of the form, it automatically fills the same information in all areas.  How can I stop this

    If you don't have Adobe Acrobat Reader for free, you can not.

    It was more than likely a mistake by the creator of forms. No doubt, they have created a field copy and paste this one to create others. Usually, it's ok, but must be given to all fields different identifiers (names). All the fields with the same name will be filled with the same content.

  • How to disable BlackBerry Smartphones called Missed Call function with the same information?

    I would like to disable the who call or missed call option in my log files because they report the same information. Can anyone help?

    Thank you.

    Remi

    Rémi, press the Green dial button to open your call log > Menu > Options > call Loggin and check NO or any other option you want. RECORD.

  • Grouping of consecutive rows with the same value?

    Hello

    I have a table in which are three columns:
    ROWID  SHOPNAME
    1      SHOP_C      
    2      SHOP_A      
    3      SHOP_C      
    4      SHOP_C      
    5      SHOP_A      
    6      SHOP_A      
    7      SHOP_C      
    8      SHOP_B      
    9      SHOP_B      
    10     SHOP_E     
    11     SHOP_A      
    12     SHOP_D      
    13     SHOP_D      
    14     SHOP_F      
    15     SHOP_G      
    16     SHOP_F      
    17     SHOP_C      
    18     SHOP_C      
    19     SHOP_C      
    20     SHOP_C      
    ROWID is a primary key with a unique ID column
    Shopname is varchar2 column

    I want to make groupings of each value 'shopname""order by ROWID"such that when there are consecutive lines of the same group shopname remains same and as soon as there is a different value in shopname column for the next line changes to"group ".


    My desired output is with the 3rd column of groups as follows:
    ROWID  SHOPNAME    Groups
    1      SHOP_C      1
    2      SHOP_A      2
    3      SHOP_C      3 ------> same grouping because Shop name is same 
    4      SHOP_C      3 ------> same grouping because shop name is same
    5      SHOP_A      4 ----> different shopname so group changed.
    6      SHOP_A      4 ----> same group as above because shopname is same
    7      SHOP_C      5
    8      SHOP_B      6
    9      SHOP_B      6
    10     SHOP_E      7
    11     SHOP_A      8
    12     SHOP_D      9
    13     SHOP_D      9
    14     SHOP_F      10
    15     SHOP_G      11
    16     SHOP_F      12
    17     SHOP_C      13
    18     SHOP_C      13
    19     SHOP_C      13
    20     SHOP_C      13
    I want be done via Analytics, so that I can partition by clause for different stores in different cities

    concerning
    Ramis.
    with data(row_id, shop) as
    (
    select 1,      'SHOP_C' from dual union all
    select 2,      'SHOP_A' from dual union all
    select 3,      'SHOP_C' from dual union all
    select 4,      'SHOP_C' from dual union all
    select 5,      'SHOP_A' from dual union all
    select 6,      'SHOP_A' from dual union all
    select 7,      'SHOP_C' from dual union all
    select 8,      'SHOP_B' from dual union all
    select 9,      'SHOP_B' from dual union all
    select 10,     'SHOP_E' from dual union all
    select 11,     'SHOP_A' from dual union all
    select 12,     'SHOP_D' from dual union all
    select 13,     'SHOP_D' from dual union all
    select 14,     'SHOP_F' from dual union all
    select 15,     'SHOP_G' from dual union all
    select 16,     'SHOP_F' from dual union all
    select 17,     'SHOP_C' from dual union all
    select 18,     'SHOP_C' from dual union all
    select 19,     'SHOP_C' from dual union all
    select 20,     'SHOP_C' from dual
    ),
    get_data as
    (
      select row_id, shop,
             lag(shop) over (order by row_id) prev_shop
        from data
    )
    select row_id, shop,
           sum(case when shop = prev_shop
                      then  0
                      else 1
                      end
                ) over (order by row_id) grps
      from get_data;
    
    ROW_ID SHOP   GRPS
    ------ ------ ----
         1 SHOP_C    1
         2 SHOP_A    2
         3 SHOP_C    3
         4 SHOP_C    3
         5 SHOP_A    4
         6 SHOP_A    4
         7 SHOP_C    5
         8 SHOP_B    6
         9 SHOP_B    6
        10 SHOP_E    7
        11 SHOP_A    8
        12 SHOP_D    9
        13 SHOP_D    9
        14 SHOP_F   10
        15 SHOP_G   11
        16 SHOP_F   12
        17 SHOP_C   13
        18 SHOP_C   13
        19 SHOP_C   13
        20 SHOP_C   13 
    
     20 rows selected 
    
  • rows with the same value

    Hello
    I have this request:
    Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;

    By request I see the lines where the handle columns have the same values?
    Thank you.

    Hello

    First thing is that your question is very abstract, we can not know which data table you is central to the present moment.

    Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
    By request I see the lines where the handle columns have the same values?

    What you mean you 'same' values with what data need to be compared to 'the same '.
    Fact it is same or some values.

    -Pavan Kumar N

  • With one of several rows with the same value for the same ID

    Hello

    I have this request:

    SELECT

    Count (case when EXISTS ())

    SELECT *.

    FROM business_log bl, su topic

    WHERE su.ID_SUBJECT = s.ID_SUBJECT

    and bl.id_subject = su.id_subject

    AND bl.value = 'resolved '.

    )

    then 1 end another null) num_solved

    OF THE subject

    It is possible that a subject is more than once 'resolved' in the table BUSINESS_LOG

    I want to count only one line solved for a topic.

    I need to use only under RESERVE the table in the main query due to other counts.

    Thank you very much.

    Concerning

    Milos

    Post edited by: 2796614

    in the examples before we talked abount 'Resolved' instead of 'resolved' as in your last example... to let you know, how it is stored.

    I had advice is not to use SEPARATE.

    So what... the evidence that any other question is faster than anything goes business_log, filter lines and can count distinct keys...

    separate within a group function is not the same thing as do select distinct...

    HTH

  • Windows 7 is not mapped to a network drive with the same information that works with Vista

    I'm trying to map a network drive that connects via a VPN.

    The exact information and references work very well on an old Vista machine but do not work on my Win 7 Professional machine.
    Thanks in advance.
    Ray

    Hello

    I would recommend posting your query in the TechNet Forums.

    http://social.technet.Microsoft.com/forums/en/w7itpronetworking/threads

    They will be able to guide you to the best.

  • Connect many clips with the same information for a particular column

    I have 1000's of clips to open a session before I begin to change it, to share many common info such as day clips # or the name of the sponsor, location, etc.

    What would be the procedure and is there an easy way to select many clips and choose or enter information such as the date or location, etc. and have all selected clips connect this info. FCP had a very simple way to do this and would actually keep or mount the database that you enter and makes it really easy to connect many clips at once.

    Your help is greatly appreciated.

    You can select multiple clips in the tray at the same time.  When you go in the metadata Panel, the fields that can be entered massively will be available.

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    Yes, no extra accommodation payment is required. After editing your site and savings, click download file to the host of VTT... The info should auto fill with the same information that you used to download the site the first time. You can choose to download only files "changed" or "all files". Click OK and the old files will be overwritten.

  • How can I download the new update on my Macbook pro when the password is not working? When I connect to the Adobe site with the same user name and password it DOES not work. I don't understand why.

    So I have a macbook pro - and she advised me that I had to update my Adobe flash player. So I go through all the steps and I'm stuck at the last stage, where he asks me my user name and password. I go in there correctly - several times and it does NOT connect. He shakes to show that there's an error. Double check my file AND I go to the Adobe site to connect with the same information. and it works very well.

    WHAT IS THE PROBLEM? Help please.

    Could you please try ComputerName administrator as username and the password as password.

    I hope this works.

    Concerning

    Hervé Khare

  • How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    I have a table whose columns with values such as

    MINNEAŸPOLIS and ¿VV ¿A

    Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.

    Please help to write a SQL SELECT with Regexp_like query or any other option.

    Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.

    SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;

  • I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter t

    Redesign existing external hard disks and still 6 Lightroom able to find existing photos.

    I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter that has been designated by Lightroom to store my photos.  I could go into my Windows 10 and reset the player to the letter that Lightroom has given at the beginning of the external hard drive.   However, I know this can happen again, if I connect any stick USD or another device, while the external hard drive is not connected to my laptop.   I found the information that I can do the new designation of the final drive by choosing a letter it is 1/2 way or higher in the alphabet.   I would like to turn an external hard drive on a strong letter, warns we hope this previous problem.   My question is, if I already have a lot of pictures on this external hardrive with the designation of the current drive, how it becomes a higher letter and have 6 Lightroom recognizes files, now under the new designation of drive letter without having to go to each photo individually and manually force Lightroom 6 find each photo.  It would take more time than I'd like to lose.  Is there a way to get just 6 Lightroom to recognize the new disk designation has changed and is able to find all of the existing files?

    I have read the ADOBE LightRoom 6 manual and seem not to be able to find anything on how to do it.

    Any help would be welcome.

    Thank you!

    So in Windows, you can select a drive like q letter (or any other letter you want only towards the end of the alphabet)

    Then in Lightroom, you can reconnect to the photos on q: the following instructions (see specifically 4 Figure and related text)

    Adobe Lightroom - find moved or missing folders and files

  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

Maybe you are looking for

  • Difficulty of updating Firefox

    Apparently, I use an older version of Firefox. I've been going round in circles trying to do a manual upgrade. I'm SO frustrated! I can't find the page to make the first move! 1. at the top of the Firefox window click the Firefox button, hover over t

  • DVD decoders

    I need to load a compatible dvd decoder on a computer on which I put a new dvd in. Can I download one on a flash drive and load it into the computer?

  • Computer goes to a loop of reboot after Windows update

    After a complete restoration of the PC, tried to install the update to windows, my computer goes to a restart and stuck loop installation of updates stage 3 of 3 so went ahead and made a factory again restore but the windows updates causing the probl

  • Support PPTP and OpenVPN

    Hey guys,. at my University, we have the possibility to connect to internet using pptp or openvpn, which does the playbook takes in charge. I think this needs to be fixed because it makes useless the playbook on many universities. If you think so too

  • Pa_bc_packets

    Dear expertsCan you please give descriptions of column to the table above.IAM not able to find this table in the PATRM.Thank you