Update multiple rows based on two columns in same row

I have a 1000 rows in a table I would like to update with a unique value. This unique value is a cocatenation of two columns in teh same row.
Each row has a (i) date and a (ii) time and a (iii) date_time column. I would like to update the date_time (iii) column with a cocatenation of the (i) date and (ii) time columns.
I know how I would update a single row but how can I update multiple rows with a cocatenation of each of the two columns - i.e put a different value into the date_time column for each row?

this?
update table tab_name
set date_time =date||time
where your_condition

Similar Messages

  • Unique row based on two columns and single column

    Dear Members,
    I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
    create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
    insert into addr values('bob', 'james', '1');
    insert into addr values('bob', 'james', '1');
    insert into addr values('harry', 'bert', '1');
    insert into addr values('jimmy', 'bert', '1');
    insert into addr values('sam', 'mac', '1');
    insert into addr values('sam', 'knight', '1');
    insert into addr values('tom', 'sand', '1');
    insert into addr values('cat', 'mud', '1');
    The output of query should contain 3 rows.
    bob - james
    harry - bert or jimmy - bert [ either one of them, but not both ]
    sam - mac or sam - knight [ either one of them, but not both ]
    tom - sand
    cat - mud
    SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
    Any suggestions..

    SQL> with t_data
    as
    select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
    select 'bob', 'james', '1' from dual union all
    select 'harry', 'bert', '1' from dual union all
    select 'jimmy', 'bert', '1' from dual union all
    select 'sam', 'mac', '1' from dual union all
    select 'sam', 'knight', '1' from dual union all
    select 'tom', 'sand', '1' from dual union all
    select 'cat', 'mud', '1' from dual
    SELECT
            firstname,
            lastname,
            area
    FROM
                    SELECT
                            t.*,
                            row_number() over(partition BY firstname order by 1) rn,
                            row_number() over(partition BY lastname order by 1) rn1
                    FROM
                            t_data t
    WHERE
            rn     = 1
    AND rn1 =1 ; 
    FIRSTNAME       LASTNAME        AREA
    bob             james           1
    cat             mud             1
    jimmy           bert            1
    sam             knight          1
    tom             sand            1
    SQL>

  • Select or update a field based on a column on another row

    hi
    I have some 5000 rows for the following combination of columns. Each combination has two rows. The only difference between these two rows is an indicator field. If one row for the same combination is having indicator as 'M' the other row for the same combination should ideally have indicator 'R'. But unfortunately the other row's indicator is null.
    ie. if the first row for same combination of fields, indicator is 'M. then other one is null which should have been 'R'. If the first row is 'R' then other one is again null which should have been 'M'.
    PRODUCT_NO STATE MONTH INDICATOR
    1001 CA SEPT M
    1001 CA SEPT null
    1002 NY OCT R
    1002 NY OCT null
    Here for the first combination indicator is M and other one is null. But i need to update it to 'R' since other rows is M.
    Same way for second combination first row is R second row then should have M as indicator.
    Basically it is changing field to a value based on the value in the other rows indicator for the same combination of the above columns.
    Please help if anybody has idea to do this in simple steps
    Thanks

    Is this what you are looking for?
    WITH TABLE_A AS
    SELECT  '1001' PRODUCT_NO, 'CA' STATE,  'SEPT' MONTH,  'M' INDICATOR FROM DUAL  UNION ALL
    SELECT  '1001' PRODUCT_NO, 'CA' STATE,  'SEPT' MONTH,  null  INDICATOR FROM DUAL  UNION ALL
    SELECT  '1002' PRODUCT_NO, 'NY' STATE,  'OCT' MONTH,  'R' INDICATOR FROM DUAL  UNION ALL
    SELECT  '1002' PRODUCT_NO, 'NY' STATE,  'OCT' MONTH, NULL INDICATOR FROM DUAL UNION ALL
    SELECT  '1003' PRODUCT_NO, 'LA' STATE,  'NOV' MONTH,  'R' INDICATOR FROM DUAL  UNION ALL
    SELECT  '1003' PRODUCT_NO, 'LA' STATE,  'NOV' MONTH, 'M' INDICATOR FROM DUAL
    SELECT
    PRODUCT_NO,
    STATE,
    MONTH,
    DECODE(A.INDICATOR,NULL,(SELECT DECODE(B.INDICATOR,'R','M','R')  FROM TABLE_A B WHERE B.PRODUCT_NO = A.PRODUCT_NO AND B.STATE = A.STATE AND B.MONTH = A.MONTH AND B.INDICATOR IS NOT NULL), A.INDICATOR) INDICATOR
    FROM
    TABLE_A A

  • How to split rows based on two columns..

    Hi all...
    I have a requirement.
    I have product column, sell, purchace prices..(total of three columns) in a data set.
    my data set is such a way that..if sale price exists...there is no purchase price and vice versa..
    I need too present in a report ,two tables:
    table 1 consists of only Sale price items
    table 2 should contain only Pruchase Items.
    Please see the below picture for clear understanding..
    Is that doable? Where do we need to impose a condition?I tried to impose a condition but,it didnt seem to work
    http://i51.tinypic.com/29xfdc6.jpg
    Please help.

    Can you send me the template and xml file to [email protected]? I can try to help.
    Did you try to filter out the records by the sale price or purchase price column not equal to null?
    Thanks,
    Bipuser

  • Update column based on two columns

    Hi,
    MinValue     MaxValue    Desc
    -1                -1    
    -1                 1    
    -1                 2    
    0                  0    
    0                  1    
    0                  2 
    The above is my table which is having three columns MinValue, MaxValue, Desc. First two columns have data and I need to update the 3rd column 'Desc' based on two columns data.
    I need to update like,
    when MinValue=-1 and MaxValue=-1 then 'NotSpecified'
    when MinValue=-1 and MaxValue=1 then 'Up to 1'
    when MinValue=-1 and MaxValue=2 then 'Upto 2'
    when MinValue=0 and MaxValue=1 then 'At lest 1'
    when MinValue=0 and MaxValue=2 then 'At least 2'
    when MinValue=0 and MaxValue=3 then 'At least 3'
    The data in 'MaxValue' is like 1,2,3,4,5...50. So for each description it should append this value as mentioned above(till 'Up to 50', 'At least 50'). How can I do this with case statement?
    Thanks,
    Gangadhar

    declare @T table ( MinValue int,MaxValue int, [Desc] nvarchar(100) );
    insert @T ( MinValue, MaxValue )
    values ( -1, 1 ) , ( -1, 1 ) , ( -1, 2), ( 0, 0), ( 0, 1), ( 0, 2)
    select *
    from @T
    update @T
    set [Desc] = case
    when MinValue=-1 and MaxValue=-1 then 'NotSpecified'
    when MinValue=-1 and MaxValue=1 then 'Up to 1'
    when MinValue=-1 and MaxValue=2 then 'Upto 2'
    when MinValue=0 and MaxValue=1 then 'At lest 1'
    when MinValue=0 and MaxValue=2 then 'At least 2'
    when MinValue=0 and MaxValue=3 then 'At least 3'
    end
    select *
    from @T
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Multiple values from same column in diffetent columns in same row??

    Hi all,
    I am wondering how you can display different values from the same column into different columns on same row. For example using a CASE statement I can:
    CASE WHEN CODE IN ('1', '3') THEN COUNT( ID) END as "Y"
    CASE WHEN CODE NOT IN ('1', 'M') THEN COUNT( ID) END as "N"
    Yes this will produce two columns needed but will also produce two separate records and null values for the empty's.
    Any ideas?
    Thanks

    It's not clear what you want.
    Can you post some examples as described in the FAQ: {message:id=9360002}
    As my first guess, I would think you're looking for something like...
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    14 rows selected.
    SQL> select count(case when deptno in (10,20) then deptno end) as deptno_10_20
      2        ,count(case when deptno > 20 then deptno end) as deptno_30plus
      3  from emp;
    DEPTNO_10_20 DEPTNO_30PLUS
               8             6

  • Merge Two Rows of a table to One row but into two columns

    Hi
    I Am struck in writing a query to merge two rows into two columns of one row.
    Here is the Sample data i am working with,
    Col 1     Col 2     Col3 Col4 Col Col6
    5000     573-3000 2     0     Phone      
    5000     573-3036 1     0          Fax
    5000     893-5703 3     0     WOrk      
    3000     232-5656     1     0     Phone     
    3000     353-5656     2     0          FAx
    Here Col,Col3,Col4 form the Key.
    now wht i am trying to do is to Merge these type of rows put them into Columns P,F,W,E respectively to achive a Structure as below
    Col1      P     F     W
    5000     573-3000      573-3036      893-5703
    3000     232-5656     353-5656     
    Can you please help me how could i do this.
    I am pretty ordinary at writing SQL's.
    Thanks a Lot in Advance
    Message was edited by:
    Sreebhushan

    Search the forum for PIVOT and you'll find plenty of examples.

  • Deleting duplicate rows based on three columns in Oracle 8i

    Hi all,
    The database we use is Oracle 8i.
    The query below raises the too_many_rows exception when I launch an application. So I want to delete the duplicated rows :
    select polarisation_1, polarisation_2
    into v_pol1_tech, v_pol2_tech
    from v_cfh_lien_element
    where nom_lien = p_nom_lien
    AND num_canal_1 = p_num_canal_1
    AND freq_emise_1 = p_freq_emise_1;
    Notice that with many possible values of the parameters p_nom_lien, p_num_canal_1 and p_freq_emise_1 then the exception is raised.
    So how to delete generally the duplicated rows based on the three columns "nom_lien" , "num_canal_1" and "freq_emise_1" ?
    Thank you very much indeed.

    Check the other thread with same question deleting duplicate rows based on three columns in Oracle 8i

  • Sorting based on two columns in report

    Hi,
    we have one issue on sorting based on two columns in report.
    In the report we are doing sorting on two columns(week_id and stage_name). I have attached the screen shot for the same. The sorting is first done on the week_id and then on the stage_name. The issue comes when we have no data for the stage 1 - Prospect in W1. The stage goes to the second position.
    Please suggest if there is any work around to show the 1 - Prospect stage in W1.
    Regards,
    Ambika Nanda.

    what is w1? where is screenshot? and is stage seoncd sort? if so what is the issue?

  • Color report rows based on a value in that row

    I would like to Color report rows based on a value in that row.
    For examplle with the "EMP" table:
    I would like job=MANAGER to be red and job=CLERK to be green etc etc
    The other example I found only had the option of one color either the highlight or the default color.
    I am looking for a way to do multiple colors.

    Hi,
    In the row template, you can use #1#, #2#, etc to indicate where a field in the report needs to be output. This does not have to be plain text - ie, you can use it within style tags if you like.
    So, take a query like:
    SELECT EMPNO,
    ENAME,
    DEPTNO,
    DECODE(DEPTNO, 10, 'green', 20, 'red', 30, 'cyan', 'white') BG_COLOUR
    FROM EMPYou get columns 1=empno, 2=ename, 3=deptno and 4=bg_colour. In the row template, you can then do:
    Before Rows setting (sets up the table):
    <table>
    <tr><td>ID</td><td>Name</td><td>Dept</td></tr>After Rows setting (closes the table):
    </table>Row Template 1 (used for ALL rows):
    <tr style="background-color:#4#;"><td>#1#</td><td>#2#</td><td>#3#</td></tr>Then, for every row, the colour that has been calculated using the DECODE function will be used in the style tag to colour the background for the entire row.
    How you determine the colours is up to you. I've used DECODE here, but you could use a field on the DEPT table to hold this and use this in your SQL statement.
    Andy

  • BC4J Objects with PKs based on two columns using multiple sequences

    I have implemented a BC4J object that is based on a DB table that has two columns as the primary key. For example Table A's primary key is Group and ID and there is a DB sequence for each Group.
    I use the BC4J object using servlets and JSPs and I have been able to implement an Update form.
    I now want to implement a Create (New) form. I've read forum postings and info on the help regarding using the SequenceImpl class to override the EntityImpl object's create method as shown below:
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    SequenceImpl mySeq = new SequenceImpl("MY_SEQ",getDBTransaction());
    setMyObjectId(mySeq.getSequenceNumber());
    But as you can see I need to know the value of the group attribute before I can get the next value sequence:
    For new EO belonging in Group1 I need sequence from "GROUP1_SEQ", Group 2 from "GROUP2_SEQ", etc.
    I would like to put this code in the Entity Object where it belongs. I guess my problem is simply how to create a new row in the View Object with a passed parameter which is the value of Group.
    Thanks in advance!

    Angelo:
    How is the EO suppose to receive the group id? Is it from the view row? If so, the VO can pass that group id to the EO through the attribute list and calling the
    public Row createAndInitRow(AttributeList nvp);
    API.
    Example code would be:
    ViewObject myVO;
    // myVO is initialized
    AttributeList nvp = new oracle.jbo.NameValuePairs();
    // GroupID is the attr name of the Group ID
    nvp.setAttribute("GroupID", <some-value>);
    Row row = myVO.createAndInitRow(nvp);
    If you do that the create(AttributeList attributeList) method of the EO will receive the GroupID value coming from the VO.
    Then, you can use that for your sequence.
    Thanks.
    Sung

  • Multiplication of two columns in a row

    Hi All,
    I have created an advanced table. In this table i am having 'price' and 'quantity' columns. i want to multiply these two columns and display result in 'amount' column in the same row.
    Please let me know how can i approach this..
    Regards,
    Murali

    Hi,
    Since Quantity , Price are entered at run time the third column Amount can be calculated only when the request to the server is made.
    Now enable PPR on the Price column , You can do this by setting the property ClientAction Action Type : FirePartialAction in the property inspector of the jdeveloper.
    Also give the event name as AmountUpdate.
    Then in the processFormRequest stage of the controller, check for the event AmountUpdate.If it is then get a handle to the row reference using pageContext.getParameter(EVENT_SOURCE_ROW_REFERENCE).This will give a key that can be used to retrieve the row access.Now find this row from the ViewObject.
    Get the Quantity and price using row.getAttribute(ViewAttribute coresponding to Quantity ) .
    Set the VO attribute related to the Amount .
    So when the user tabs out of price field the amount field will be popluated thorugh PPR.
    Regards,
    Guru Krishnan V.

  • How to retrieving latest row based on a column value

    Hi,
    Lets consider a scenario. I have a table which has a order number, count column which is our fact, a type column which contains types e.g. (A,B) with A has more priority then B. Now in our graph we are getting all rows i.e. if we have two rows in db for order #1 one for type A and one for type B, then it shows us data from both rows in graph.
    But I need only to show one row of type A in this case as A has higher priority than B. The row with type B should not contribute in construction of my graph if type A for same row also exists.
    I tried a solution, for which i created a new column at logical level which contain 1 for A and 0 for B. Now i put Max aggregation rule in it to get maximum value which will be row with Type A in our case. But it did not work.
    How we will can achieve it in OBIEE?
    Thanks.
    Aasim Khan.

    Hi Steve,
    I have a similar requirement... one of the columns in my table is a calculated value based on several xml fields,
    <?xdofx:(MATH01+MATH02+MATH03+MATH04+MATH05+AA+AA1)+((FNDCD01+FNDCD02+FNDCD03+FNDCD04+FNDCD05+MCHCD01+MCHCD02) div '8')?>
    if the resultant value above is less than 62, i do no want to display this entire row in the output. could you help me wout with this?
    thanks
    Domnic

  • Parent-Child hierarchy based on two-column key

    Hello
    Is it possible to create a parent-child hierarchy, if the primary key of the table consists of two columns?
    My table looks like:
    TRACE_ID | DIAG_ID | SUPER_DIAG_ID
    with TRACE_ID and DIAG_ID as PK.
    If I define only DIAG_ID as PK, I can add a logical dimension (PC-hierarchy) without problems.
    However when I also add TRACE_ID to my PK, I cannot select a member key in the new logical dimension window and therefore not create a logical dimension.
    Is this a limitation of OBIEE and I have to merge the two colums (which would be rather bad, as there are FK relations to DIAG_ID) or is there a solution?
    Regards
    Matthias

    Dear Gowtham  ,
    I am very well aware of the level based hierarchy available in BO .
    The issue that i have raised is all about the Parent Child Hierarchy which creates the recursive query.
    I.e Every Parent has a child and that child can be parent of some other . (See the original example for more illustration)

  • Delete duplicate rows -- based on 4 columns -- how?

    I asked this question on how to delete duplicates recently and received this suggestion which works well -- except --
    With CTE AS
    SELECT *, ROW_NUMBER() OVER (Partition by fld1 order by fld1) RowNum
    FROM #tmpA
    DELETE From CTE
    WHERE RowNum > 1
    -- the actual table I need to delete duplicate rows on is based on 4 columns.  The following table contains 14,462 rows of which 14,348 are distinct -- based on the following 4 colums.  Below is an image of a sample of the data contained in the
    table for my question and to the right of that data is the column structures (data types).  Is it possible to do something like the above example suggestion with the table in the image below?  How to do that?  I need to delete rows so that 14462
    goes down to 14348.  If I only reference one column for the delete -- this would delete like 7000+ rows.  I only need to remove 114 rows.
    Rich P

    Add the other 3 columns to the partition.
    Jason Long

Maybe you are looking for

  • Oracle forms 9i on IE 8

    Dear All, We are using Oracle 9iAS as middleware and Internat Explorer (IE) 6 as client web browser on windows XP. The Jinitiator version is 1.1.8.16. Our client organisation is now planning to upgrade to IE 8. However, all I have researched till now

  • IDVD slide shows and DVD ROM contents?

    No problem making slide shows, but iDVD will not copy ALL of the hi-res pics, seems to have a mind of its own and drops short. ie. 3 slide shows of 100 pics each it will copy 87, 55, 85 hi-res pics only. 5 slide shows of 100 each it will copy 80, 52,

  • Infix Expression - Postfix Expressions

    Hello I have a program that uses 2 stacks (InfixStack and OperatorStack) to evaluate an infix expression that a user inputs. My problem is that i want to also output the postfix form of the infix expression, i know that i need another stack (PostfixS

  • Photoshop CS 6 display problem

    hello. I have problem with photoshop cs6. Drivers is ok, cs5 work correctly. I attached link: https://docs.google.com/file/d/0B8jcMJ1qN-eXV0lUOVIzbTBkVXM/edit?pli=1

  • Safari as unsupported browser for mobileme

    Has anyone found out why mobileme still claims that safari (running 3.2.1 currently) is an unsupported browser? this problem has persisted since mobileme began. the mobileme support site has no mention of this and i know many people are still having