Merge only one line on several lines

I need prepare a merge statement that merge only one line in a table. Here is the table definition, data instruction and fusion sample, I used.
      CREATE TABLE Mob_Attr (NAME VARCHAR2(20), ATTR_1 VARCHAR2(20), ATTR_2 VARCHAR2(20), ATTR_3 VARCHAR2(20));
      CREATE TABLE Mob_Desc (NAME VARCHAR2(50), ATTR_1 VARCHAR2(20), ID NUMBER(20));      
      CREATE TABLE Mob_Main (NAME VARCHAR2(20), ATTR VARCHAR2(20), ID VARCHAR2(10));     
      
      insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n1','aa',null,null);
      insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n2','bb',null,null);
      insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n3','cc',null,null);
      insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n4','dd',null,null);
      
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',10);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',15);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',123);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',1455);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',455);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',135);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',15);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',52);
      insert into Mob_Desc (NAME,ATTR_1,ID) values ('n4','dd',1455);
      
      merge into Mob_Main ma using
      (select d.name, d.attr_1,d.id from Mob_Attr a, Mob_Desc d
      where a.name = d.name and a.attr_1 = d.attr_1
      ) q on (ma.name=q.name and ma.attr=q.attr_1)
      when not matched then
      insert (NAME,ATTR,ID)
      values (q.name,q.attr_1,q.ID);
      
Merge statement above will actually merge complete data. But I want that the first line will only get inserted to the base table (Mob_Main). If we take the "n1" name first row in the table with the ID Mob_Desc '10' should get only inserted. I go for a cursor to do what I have given huge volume, I prefer the merger instead.
MERGE INTO Mob_Main ma
     USING (
              SELECT distinct d.name, d.attr_1, first_value(d.id) over (partition by d.name, d.attr_1 order by d.rowid) id
              FROM Mob_Attr a, Mob_Desc d
              WHERE a.name = d.name AND a.attr_1 = d.attr_1
             ) q
        ON (ma.name = q.name AND ma.attr = q.attr_1)
WHEN NOT MATCHED
THEN
   INSERT     (NAME, ATTR, ID)
       VALUES (q.name, q.attr_1, q.ID);
COMMIT;

select *
from Mob_Main
order by name, id;

NAME                 ATTR                 ID
-------------------- -------------------- ----------
n1                   aa                   10
n2                   bb                   455
n3                   cc                   15
n4                   dd                   1455      

4 rows selected.

Tags: Database

Similar Questions

  • need to get only one line when you use between (date columns)

    Hi all

    create the table SAMPLE_ITEMS

    (ITEM_NO, varchar2 (10))

    Date DELIVERY_DATE,

    Number of QTY_SUM1

    Number of QTY_SUM2

    Number ITEM_QTY,

    Number ORDER_QTY,

    Number ITEM_AMOUNT,

    Number of SALES_AMOUNT

    );

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 04/2014 ',-88, 0,475,262,-123.45,-1188);

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 05/2014 ', 0, - 122, 475, 262, - 10.234,-1647);

    insert into SAMPLE_ITEMS values ('AAA', ' 16 / 06/2014. ', 0, 0,475,262,-80.59,-135);

    insert into SAMPLE_ITEMS values ('AAA', 19 December 2014 ', 0, 0,475,262,-42.29,-67.5);

    Setting out with my own query,

    ITEM_NOTRUNC (DELIVERY_DATE)QTY_SUM1QTY_SUM2ITEM_QTYORDER_QTYITEM_AMOUNTSALES_AMOUNT
    AAA28/04/2014-880475262-123.45-1188
    AAA28/05/20140-122475262-10.234-1647
    AAA16/06/201400475262-80.59-135
    AAA19/12/201400475262-42.29-67.5

    Every time I question as code

    Select * from SAMPLE_ITEMS

    where DELIVERY_DATE between April 28, 2014 ' and 19 December 2014 '-> they must pass as a parameter

    I need to get only one line

    AAA-88-122475262-256.564-3037.5

    Database 11.2.0.1.0

    Note; Please do not use MAX for Date and do not want to display Date columns in the result

    Note 1: I want to choose DELIVERY_DATE in select it also and only get a line like above the expected result

    SELECT item_no

    SUM (qty_sum1),

    SUM (qty_sum2),

    SUM (DISTINCT item_qty),

    SUM (DISTINCT order_qty),

    SUM (item_amount),

    SUM (sales_amount)

    OF SAMPLE_ITEMS

    WHERE the DELIVERY_DATE BETWEEN TO_DATE (28 April 2014 ', "dd/mm/yyyy")

    AND TO_DATE (19 December 2014 ', "dd/mm/yyyy")

    GROUP BY item_no;

    I will get

    ITEM_NO Trunc (DELIVERY_DATE) QTY_SUM1 QTY_SUM2 ITEM_QTY    ORDER_QTY TTEM_AMOUNT SALES_AMOUNT        

    AAA             12/19/2014                         -88                 -122                475                262                       -256.564              -3037.5

    OK fine, I want to choose DELIVERY_DATE as if so I'll have all the lines, but I want to only show one as shown above

    Because I do report discoverer in Oracle Apps, without taking the DELIVERY_DATE of the select query, it is not possible to move the date as a parameter

    Can you please help me how to do this?

    Thank you

    Post edited by: Rajesh123 NOTE added in the body of the Message

    Post edited by: added test Rajesh123 messages

    Maybe you want a single line in all cases

    Select si.item_no,

    start_date min (d.start_date),

    min (d.end_date) end_date,

    min (si.qty_sum1) qty_sum1,

    min (si.qty_sum2) qty_sum2,

    min (si.item_qty) item_qty,

    min (si.order_qty) order_qty,

    Sum (si.item_amount) item_amount,

    Sum (if. Sales_Amount) sales_amount

    of (start_date select to_date(:date_from,'dd-MON-yyyy'))

    to_date(:date_to,'dd-mon-yyyy') end_date

    of the double

    ) d

    left outer join

    TR sample_items

    on the si.delivery_date between d.start_date and d.end_date

    Group of item_no

    ITEM_NO START_DATE END_DATE QTY_SUM1 QTY_SUM2 ITEM_QTY ORDER_QTY ITEM_AMOUNT SALES_AMOUNT
    - 01/01/1900 31/12/2000 - - - - - -

    Concerning

    Etbin

  • Link from Oracle to MySQL database select only one line

    Hello

    I created a connection to the batabase Oracle 11.2 to a MySQL database via a database link. The following statement shows that 35 lines are in the mySQL table:

    SQL > select count (*) from 'main_pages"@MOREWEB;

    COUNT (*)

    ----------

    35

    But a normal select statement only return 1 row.

    SQL > select 'subject' of 'main_pages"@MOREWEB;

    Object

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

    Übersicht: references

    I use the mysql-connector-odbc driver - 3.51.30 - winx64. One is the newer version be installed because on Windows Server 2008 R2, I get an error with a missing dll file. The DataDirect ODBC driver is not possible, because we like to use the MySQL-database free one only support for DataDirect enterprise edition.

    I have also tried to limit the HS_OPEN_CURSORS or do not limit the HS_FDS_FETCH_ROWS, but there is no difference in the result. I always get only one line.

    HS Init.ora

    # This is an example of initialization file of the agent that contains the HS settings

    # necessary for the database to ODBC gateway

    #

    # HS init parameters

    #

    HS_FDS_CONNECT_INFO = moreweb

    HS_FDS_TRACE_LEVEL = WE

    HS_FDS_FETCH_ROWS = 1

    #

    # Required for the non-Oracle system environment variables

    #

    #set < varenv > = < value >

    HS trace file

    Oracle Corporation - MITTWOCH 5 November 2014 13:56:22.066

    Heterogeneous Agent release

    11.2.0.1.0

    Oracle Corporation - MITTWOCH 5 November 2014 13:56:22.066

    Version 11.2.0.1.0

    HOSGIP to 'HS_FDS_TRACE_LEVEL' returned 'ON '.

    HOSGIP to 'HS_OPEN_CURSORS' returned '50 '.

    HOSGIP to 'HS_FDS_FETCH_ROWS' returned '1 '.

    HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536".

    HOSGIP to 'HS_NLS_NUMERIC_CHARACTER' returned '. "

    HOSGIP to 'HS_KEEP_REMOTE_COLUMN_SIZE' returned 'OFF '.

    HOSGIP for "HS_FDS_DELAYED_OPEN" returns 'TRUE '.

    HOSGIP to 'HS_FDS_WORKAROUNDS' returned '0 '.

    HOSGIP to 'HS_FDS_MBCS_TO_GRAPHIC' returned 'FALSE '.

    HOSGIP to 'HS_FDS_GRAPHIC_TO_MBCS' returned 'FALSE '.

    HOSGIP to 'HS_FDS_RECOVERY_ACCOUNT' returned 'RECOVER '.

    HOSGIP for "HS_FDS_TRANSACTION_LOG" returns "HS_TRANSACTION_LOG".

    HOSGIP to 'HS_FDS_TIMESTAMP_MAPPING' returned 'DATE '.

    HOSGIP to 'HS_FDS_DATE_MAPPING' returned 'DATE '.

    HOSGIP to 'HS_FDS_CHARACTER_SEMANTICS' returned 'FALSE '.

    HOSGIP for "HS_FDS_MAP_NCHAR" returns 'TRUE '.

    HOSGIP to 'HS_FDS_RESULTSET_SUPPORT' returned 'FALSE '.

    HOSGIP to 'HS_FDS_RSET_RETURN_ROWCOUNT' returned 'FALSE '.

    HOSGIP to 'HS_FDS_PROC_IS_FUNC' returned 'FALSE '.

    HOSGIP to 'HS_FDS_REPORT_REAL_AS_DOUBLE' returned 'FALSE '.

    using mpgw as the default value to "HS_FDS_DEFAULT_OWNER".

    HOSGIP to 'HS_SQL_HANDLE_STMT_REUSE' returned 'FALSE '.

    SQL text of hgopars, id = 1, len = 36...

    45 00: 53454 C 43542043 4F554E54 282 HAS 2920 [COUNT (*) SELECT]

    10: 46524F4D 20606D 61 696E5F70 61676573 [FROM ' main_pages]

    20: 60204131 [' A1]

    Delayed open until the first fetch.

    Deferred execution open.

    SQL text of hgopars, id = 1, len = 40...

    45 00: 53454 C 43542041 312E6073 75626 has 65 [SELECT A1.' subje(1)]

    10: 63746020 46524F4D 20606D 61 696E5F70 [ct' FROM ' main_p]

    20: 61676573 60204131 [ages A1]

    Delayed open until the first fetch.

    Deferred execution open.

    Please can someone help me.

    Thank you.

    Bianca

    Bianca,

    Everything I've read on this point to a need to install/reinstall the Microsoft Visual C++ Redistributable Package for windows OS 2008.

    You will need to download the appropriate version for your microsoft form system.  There is a lot of information on this topic.  Just

    search on the web, and it should help you in the right direction.

    Thank you!
    Matt

  • table is expected to insert only one line

    Hi all

    my need is to create the table that allows to insert only one line.

    How can I make it?

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

    PL/SQL Release 11.2.0.1.0 - Production

    "CORE 11.2.0.1.0 Production."

    AMT for Linux: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    Hello

    2621671 wrote:

    Hi all

    my need is to create the table that allows to insert only one line.

    How can I make it?

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

    PL/SQL Release 11.2.0.1.0 - Production

    "CORE 11.2.0.1.0 Production."

    AMT for Linux: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    You can create a unique Index based on a function, like this:

    CREATE UNIQUE INDEX table_x_u ON table_x (NVL2 (col_1, 1, 1));

    You can use any column of any data type.  In other words, the function may return a NUMBER, if the column referenced in the function is a NUMBER.

    Regardless of whether the column is NULL or not; not more than 1 rank is authorized.

  • Subtotals - delete if there is only one line?

    I'm sure I know the answer to that, but is there a way of subtotals to remove if there is only one line? It doesn't seem to be any documented to do this, but I wonder if anyone has found a kind of workaround...? ... Registry entry?

    I am using Desktop, verision 10.1.2.2

    Thank you!

    Hello
    There is no global setting, but you can remove them on a basis of total per total.

    You change the total and check the box that says do not appear in total for a single line, but like I said you need to do this on a basis of total per total.

    Best wishes
    Michael

  • How select only one line

    Hello
    I have a select query that returns a couple of lines.
    now, I would like for the query to return only one row (the first match it can find).
    How do I do that?
    Thank you!

    my sample of my data as below, the registration of the first and the second is equal and I want the column of the first row and ignore the second row.


    9410 20110812 84A8E46E8C97
    9420 20110813 84A8E46E8C97
    84A8E46E8C6E 20110816 9410
    9400 20110819 84A8E46E8AFA

    You can try

      SELECT msid, bsid, starttime
        FROM (SELECT msid, bsid, starttime, ROW_NUMBER () OVER (PARTITION BY msid ORDER BY msid, starttime) rn FROM aaa_bill)
       WHERE rn = 1
    ORDER BY 1, 3
    
  • Get only one line for each type of a column

    Hello!
    I have a little problem.

    I have a table with 10 columns. One of them has repeated values. My goal is to get all the lines with this column only once for each values he holds.

    Ex:

    Col1 Col2 Col3
    A A A A
    B B B
    C A C
    D C D


    Column 2 has repeated values. My goal is to get:

    A A A A
    B B B
    D C D

    Only once each value in column 2.

    Thank you guys! ;)
    SQL>  CREATE TABLE Tbl (col1 VARCHAR2(1),col2 VARCHAR2(1),col3 VARCHAR2(1));
    
    Table created.
    
    SQL> INSERT INTO Tbl VALUES ('A','A','A');
    
    1 row created.
    
    SQL>              INSERT INTO Tbl VALUES ('B','B','B');
    
    1 row created.
    
    SQL>              INSERT INTO Tbl VALUES ('C','A','C');
    
    1 row created.
    
    SQL>              INSERT INTO Tbl VALUES ('D','C','D');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT min(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    
    C C C
    - - -
    A A A
    B B B
    D C D
    
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT max(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    
    C C C
    - - -
    B B B
    C A C
    D C D
    

    Published by: Johan August 3, 2010 01:31

  • DCBindingIterator refresh only one line

    Hi all!

    Is that what someone can say, is there a chance to refresh only a current record in the DCBindingIterator?

    Now I do it like that
    JUIteratorBinding it = ELExp.getIterator("TestIterator");
    String saveRowKey = it.getCurrentRowKeyString();
    it.executeQuery();
    it.setCurrentRowWithKey(saveRowKey);
    But I think that's not very optimal.

    Thank you!

    Hello

    oracle.jbo.Row has a refresh() method that allows you to refresh a single row of for example the database or simply for unspecified changes.

    Line rw = it.getCurrentRow ();
    RW. Refresh (Row.REFRESH_UNDO_CHANGES);

    http://download.Oracle.com/otn_hosted_doc/JDeveloper/1012/bc4jjavadoc/RT/Oracle/JBO/row.html

    Frank

    Published by: Frank Nimphius, March 6, 2012 20:42

  • So that to joining 3 tables make me 2 ranks, real, I need only one line

    Hi all

    While joining 3 tables make me 2 rows, I need 1 row.

    Please find my request and the actual output and the expected results.

    Help me handle this.

    Select

    -MFU_D_C_INVESTOR_ID_DET,

    mfu_remove_junk (Q.CAN) CAN_ST,

    mfu_remove_junk (Q.INSTALLMENT_AMOUNT) AMOUNT_ST,

    mfu_remove_junk (x.Can) can be,

    mfu_remove_junk (x.Amc_Code) Amc_Code,

    mfu_remove_junk (x.Folio_No) Folio_No,

    mfu_remove_junk (x.Order_Status) Order_Status,

    mfu_remove_junk (x.User_Code) User_Code,

    mfu_remove_junk (x.User_Txrn_No) User_Txrn_No,

    mfu_remove_junk (x.Group_Ord_No) Group_Ord_No,

    mfu_remove_junk (x.Ind_Txn_Ref_No) Ind_Txn_Ref_No,

    mfu_remove_junk (x.Pending_Txn_Ref_No) Pending_Txn_Ref_No,

    mfu_remove_junk (x.Appl_No) Appl_No,

    mfu_remove_junk (x.Ts_Machine_Id) Ts_Machine_Id,

    mfu_remove_junk (x.Trxn_Date) Trxn_Date,

    mfu_remove_junk (x.Trxn_Time) Trxn_Time,

    mfu_remove_junk (x.Timestamp_No) Timestamp_No,

    mfu_remove_junk (x.Sch_Code) Sch_Code,

    mfu_remove_junk (x.Reinv_Tag) Reinv_Tag,

    mfu_remove_junk (x.Txn_Mode) Txn_Mode,

    mfu_remove_junk (x.Trxn_Type) Trxn_Type,

    mfu_remove_junk (x.Sub_Trxn_Type) Sub_Trxn_Type,

    mfu_remove_junk (x.Units) units,

    mfu_remove_junk (x.Amount) amount.

    mfu_remove_junk (x.All_Units_Flag) All_Units_Flag,

    Entity_Id, mfu_remove_junk (x.Entity_Id),

    mfu_remove_junk (x.ENTITY_BRANCH_ID) ENTITY_BRANCH_ID,

    mfu_remove_junk (x.Location) location,

    (TO_CHAR(sysdate,'DD-MON-RRRR'))        CREATED_DATE

    Of MFU_FTP_XML_FILES T

    Left Join Xmltable ('/ COMM_TXN_STRUCT/FILE_ROWS/FILE_ROW ')

    By the way T.Filecontent

    Columns

    -MFU_D_C_INVESTOR_ID_DET

    Can Varchar2 (500) path ' INVESTOR_ID_DET / CAN'.

    Path of Varchar2 (500) Amc_Code "INVESTOR_ID_DET/AMC_CODE,"

    Path of Varchar2 (500) Folio_No "INVESTOR_ID_DET/FOLIO_NO,"

    Path of Varchar2 (500) Order_Status ' TRANSACTION_DET/ORDER_STATUS. "

    Path of Varchar2 (500) User_Code "TRANSACTION_DET/USER_CODE,"

    Path of Varchar2 (500) User_Txrn_No "TRANSACTION_DET/USER_TXRN_NO,"

    Path of Varchar2 (500) Group_Ord_No "TRANSACTION_DET/GROUP_ORD_NO,"

    Path of Varchar2 (500) Ind_Txn_Ref_No "TRANSACTION_DET/IND_TXN_REF_NO,"

    Path of Varchar2 (500) Pending_Txn_Ref_No "TRANSACTION_DET/PENDING_TXN_REF_NO,"

    Path of Varchar2 (500) Appl_No "TRANSACTION_DET/APPL_NO,"

    Path of Varchar2 (500) Ts_Machine_Id "TRANSACTION_DET/TS_MACHINE_ID,"

    Path of Varchar2 (500) Trxn_Date "TRANSACTION_DET/TRXN_DATE,"

    Path of Varchar2 (500) Trxn_Time "TRANSACTION_DET/TRXN_TIME,"

    Path of Varchar2 (500) Timestamp_No "TRANSACTION_DET/TIMESTAMP_NO,"

    Path of Varchar2 (500) Sch_Code "TRANSACTION_DET/SCH_CODE,"

    Path of Varchar2 (500) Reinv_Tag "TRANSACTION_DET/REINV_TAG,"

    Path of Varchar2 (500) Txn_Mode "TRANSACTION_DET/TXN_MODE,"

    Path of Varchar2 (500) Trxn_Type "TRANSACTION_DET/TRXN_TYPE,"

    Path of Varchar2 (500) Sub_Trxn_Type "TRANSACTION_DET/SUB_TRXN_TYPE,"

    Units Varchar2 (500) Path TRANSACTION_DET/UNITS"."

    Amount Varchar2 (500) path ' TRANSACTION_DET/AMOUNT. '

    Path of Varchar2 (500) All_Units_Flag "TRANSACTION_DET/ALL_UNITS_FLAG,"

    Path of Varchar2 (500) Entity_Id ' TRANSACTION_DET/ENTITY_ID. "

    Path of Varchar2 (500) ENTITY_BRANCH_ID "TRANSACTION_DET/ENTITY_BRANCH_ID,"

    Path of Varchar2 (500) "TRANSACTION_DET/RENTAL.

    ) X

    (1 = 1)

    the left join XMLTABLE ('/ CT_SYS_STRUCT/FILE_ROWS/FILE_ROW ')

    PASSAGE T.FILECONTENT

    columns

    CAN varchar2 (500) PATH ' INVESTOR_ID_DET / CAN'.

    INSTALLMENT_AMOUNT varchar2 (500) PATH "TRANSACTION_DET/INSTALLMENT_AMOUNT".

    ) Q

    (1 = 1)

    Where

    TRUNC ((TO_DATE (T.RETRIVED_DATE, 'DD-MON-RRRR HH PM'))) = TRUNC(SYSDATE-2)

    Order By X.Can Asc, Rownum;

    O/P: real

    15114LBA01 1000.00 (null) (null) (null) (null) (null) (null) (null)

    (null)      (null) 15114LBA01 SMF AC UGM 40715117000 15114010001 1511401000102

    O/P: expected

    amount can_st peut amc command user trxn_no group_ord ind_txn_no

    1000.00 15114LBA0115114LBA01 SMFCA40715117000 15114010001 1511401000102 UGM

    It would have been helpful if you had your more detailed condition described in brief.

    For as far as I understand nothing xmldata in every line of MFU_FTP_XML_FILES can you wheter structure COMM_TXN_STRUCT or CT_SYS_STRUCT.

    So what about something like below

    Select

    x.*

    , q.*

    sysdate

    de)

    Select

    x.cols

    MFU_FTP_XML_FILES t

    , Xmltable ('/ COMM_TXN_STRUCT/FILE_ROWS/FILE_ROW ')

    By the way T.Filecontent

    Columns

    the_x_cols

    ) x

    Where

    TRUNC ((TO_DATE (T.RETRIVED_DATE, 'DD-MON-RRRR HH PM'))) = TRUNC(SYSDATE-2)

    ) x

    Join

    -a full outer join if there are cans without match

    (

    Select

    q.cols

    MFU_FTP_XML_FILES t

    , XMLTABLE ('/ CT_SYS_STRUCT/FILE_ROWS/FILE_ROW ')

    PASSAGE T.FILECONTENT

    columns

    CAN varchar2 (500) PATH ' INVESTOR_ID_DET / CAN'.

    INSTALLMENT_AMOUNT varchar2 (500) PATH "TRANSACTION_DET/INSTALLMENT_AMOUNT".

    ) q

    Where

    TRUNC ((TO_DATE (T.RETRIVED_DATE, 'DD-MON-RRRR HH PM'))) = TRUNC(SYSDATE-2)

    ) Q

    on (x.can = q)

    Order By X.Can Asc, Rownum;

  • How to add asterics to line when an item in the line splits into two and only one line display.

    
    
    

    Here, the title is a bit confusing, I completely realize that but here's what I'm trying to accomplish. I have a table with a column that repeats.

    the table looks like this.

    create table testCheck (check_num varchar2(20), amount number(17,2), invh_Code varchar2(20))
    
    

    and it contains data as follows

    INSERT INTO "TESTCHECK" (CHECK_NUM, AMOUNT, INVH_CODE) VALUES ('001', '50', '1123')
    INSERT INTO "TESTCHECK" (CHECK_NUM, AMOUNT, INVH_CODE) VALUES ('001', '50', '1123')
    INSERT INTO "TESTCHECK" (CHECK_NUM, AMOUNT, INVH_CODE) VALUES ('002', '100', '1234'
    
    

    I would like to write a query that would give me of the separate check_num, but put an asterisk on the elements that are in fact double.

    so in other words expected result in this case is as follows.

    "CHECK_NUM" "AMOUNT" "INVH_CODE"
    "001*" 50 "1123"
    "002" 100 "1234"
    

    I could go as far as getting unique values, but what I can't do, it is understand for the life of me how to put the asterisk in there.

    Here's my query.

    with Checkquery as (         
    SELECT  count(*) over (partition by CHECK_NUM order by CHECK_NUM ROWS UNBOUNDED PRECEDING ) thiscount, CHECK_NUM,  AMOUNT,  INVH_CODE
    FROM  TESTCHECK
    group by
    check_num,
    AMOUNT,
    INVH_CODE)
    select check_num, amount,invh_Code from Checkquery where thiscount ='1';
    
    

    can someone tell me please in the right direction. I just want to identify the dups put an asterisk on the record and then only select records.

    According to your last post, you keep what is displayed for the other columns, so why display them at all, so this will do the job.

    SELECT check_num.

    Decode (to_char (Count (*)), '1', NULL,'* ') dup_checks

    TO define by test

    GROUP BY check_num;

    If you want to view the other columns, you have two choices. You must either put some sort of aggregate function in the list of selection, such as min, max, or sum, or they need to be part of the group.

    Concerning

    André

  • Sorting the columns showing only a line

    Hello

    I have a report of sql query that I helped sort on all columns. When I click on the header to sort a column report shows only one line.
    If anyone can help me, I would really appreciate it!

    Thank you!

    Once I met a similar problem like the one you describe. I suspect that the problem was related to the data that the report was released.
    I was able to make the problem disappear by disabling "Partial Page Refresh" for the report. Define 'NO' for the attribute "Activate partial Refresh of Page" in the page 'Report attributes' disable PPR for the report.

    CITY

  • Problem with headphone selection if the table has only one row

    Hi all

    I have developed a table in which I use selection listener to perform a task when a line is selected.
    It works fine when I have more than 1 row in the table, but when I did that one line in the table, the listener of selection do not call the corresponding method in the bean.
    I understand this selection event is raised only when the line is changed, but in the case of use when only one line is there, what do I do to make the listener of selection work?

    The selection listener I wrote the code to make the line selected as current line and perform the required task.

    Please suggest a way out of this situation.

    Thanks in advance.

    Hello

    try to remove this table attr

    selectedRowKeys="#{bindings.xxx_VO1.collectionModel.selectedRow}"
    
  • A function can receive from a keyboard event or a mouse event or there may be only one?

    I decided to add some keyboard functions to my program.  All my functions, I wrote require a mouse event to pass to them.  I wonder if there is a better way to perform these functions of mouse event rather than take the contents of these functions and create a function that is called in a mouse event function OR a function of keyboard events.

    What I mean is that I begin to change the functions of mouse event that I don't have only one line inside of them, which runs a separate function. This same separate function that I run using a keyboard to input as well.  It seems a little redundant to me. Any thoughts?  Thank you.

    In addition to other comments, since MouseEvent and KeyboardEvent extends event, you can type argument as event:

    function myHandler(e:Event):void {}

    code

    }

    The only problem with this is that if you write code within the listener based on a specific event parameter - you will need to mount e argument as such in any case.

    Another solution would be to make argument an object. In this case to the compilation and runtime it will be perceived as valid a data type:

    function myHandler(e:Object):void {}

    code

    }

    Typing is no argument at all (like e: *) can cause inconvenience more typing at least to the object.

  • I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    Yes, you can have a one word title, by assigning a paragraph style title to this one word. No, you cannot change the text in a Table of contents, but you can change paragraph style font attributes (line) and add for example, a head of points between the types of OCD paragraph and page numbers. No part of the table of contents will not provide hyperlinks in exported PDF documents.

    When you look up in the menu bar, you can see the word iPages, or simply Pages. There is no product of iPages.

  • HP deskjet 5150 does only print one line at a time

    My deskjet 5150 worked very well until another paper went through and stuck.  I was able to pull the tail of the outside before he completely crossed, thus eliminating the document.  After that, the printer went from normal to print to print one line at a time, with long breaks between the two, such that a journal would take several minutes to print.

    It happened before, and it seems that one of the many random things that I try finally works (striking out the cartridges, etc.), or he decides to forms and works correctly at some point anyway.  I don't know what is the actual active ingredient.  However, it has recovered from such behaviour several times before.

    I should mention that this malfunction/recovery routine began and most recently occurred when connected to my old iBook G4 Mac computer.  I have just this week has changed to a MacBook Pro, the latest operating system running, and the printer is not different.  It prints one line at a time.

    I don't know when this has happened to the other HP printers that I had in the past, I just put away, not realizing that they still had plenty of life in them left.  This one, I have "revived" several times already.  But how, I'm not sure!

    You have any ideas?

    Hi there chitownchic,

    I suggest paper paper jam for the troubleshooting steps that are recommended for the jamming problem you had. Generally a very good cleaning of the rollers will help a little, and also a power reset.

    "Paper jam" Error Message on the computer

    I hope that helps!

    Have a great day, thanks for posting in the community

Maybe you are looking for

  • AppleScript to choose a message in mail &amp; download the attachment

    Hello I would like to know if there is a way to prompt the user to choose a message like how we are able to choose file / folder? Above all, I would like the process to go as: Choose a mail, download his attachment, perform actions on the attachment.

  • Firefox crashes in safe mode

    Since the updated Firefox to version 22 (and later to 23), it crashes even if started in safe mode. This happens several times a day, at random intervals in different web pages. So far, I've done these things:-Reinstall clean according to http://kb.m

  • my daughter has somehow changed the size of my yahoo page and Facebook games?

    I'm reasonably good with computers and have tried the settings of resolution without change, she randomly presses a few buttons on the keyboard.

  • LabVIEW classification number

    Hi I'm looking for a quick way to labview order the numbers by class according to specified intervals. The comparison of the number of tools using just take me to a huge vi, which is difficult to manage.

  • I deleted the drivers of HP and my dvd/rw no longer works

    I removed my 64-bit Windows 7sp1 computer HP drivers.  Shortly after, I noticed that my DRV/rw not working.  Recognozed of Windows in like the DVD-RAM Device Manager and it appears when I start the computer if I want to start from, but I can't boot f