Merge two column in single column value

Team,

I have a requirement where in I need to merge 2 column values in a single column.

e.g. I Percent_complete column in my table. and my table has only one record.

I need to ask questions that I need to store the values of percent_complete and (100-percent_complete) in a single column.

ex

Percentage complete is set to 30.

I need to select the 30 and 70 (100-30) both in a single column.

Thank you

If you mean like this?

SQL > ed
A written file afiedt.buf

1 with t (select 30 as double percent_complete)
2  --
3 end of test data
4  --
5. Select decode(rownum,1,percent_complete,100-percent_complete) as percent_complete
6 t
7 * connect by rownum<=>
SQL > /.

PERCENT_COMPLETE
----------------
30
70

Tags: Database

Similar Questions

  • two column values in a single column

    Hi guys,.

    I have a requirement that i want to be viewing the two column values in a single as column... values year & product will be exposed in a unique column values

    Kind regards

    Sree

    Karthickumar Pillaiyarsamy yours is a database, in OBIEE is similar with some limitations...

    Sree! you have 2 ways to do this: by using the CONCAT function or the | operator, examples here are 2 concatenating year, a space and production:

    "Time". "" T05 annually name | ' ' || ' 'Products ' '. Product P1.

    CONCAT ("Time". "T05 per year of name', CONCAT (" ","Products".)" P1 product"))

    CONCAT in OBIEE accept only 2 params, so you if want to add a space between the 2 items, you must nest your function call.

    In case your year column is a number, you can convert it to a string using CAST ("your column" as VARCHAR (10)).

  • How to put the two column values in two different colors unique online: MobApp

    Hello

    I develop Mobile Application.
    I want to show two values in different columns in single row and first column value in either green or red and the second color the default column value.
    the first value of the column is green when the value is greater than the second value of the column.
    and the first column value in red when the value is less than the second value of the column.
    The code I tried is:
    --------------------------------------------------------------------------------------------
    < tr:panelGroupLayout layout = "vertical" styleClass = 'list' >
    < tr:panelList styleClass = "panelist ul > li > a" >


    "" < tr:outputText value = "deliver: % #{row.bindings.OccCurr.inputValue},
    inlineStyle = "background-color: #{rank." OccCurr > line. OccFcst? {'Green': 'Red'}; ">

    "< tr:outputText value =" OccFcst: #{row.bindings.OccFcst.inputValue} % ">"

    < / tr:outputText >
    < / tr:outputText >
    < / tr:panelList >
    < / tr:panelGroupLayout >
    ------------------------------------------------------------------------------------------------

    But the code above does not work.


    Please, someone tell me what I need to do.


    I apreciate your time and your help.

    Sanchez.

    Hi Catherine,

    Exactly, what is not working? Your OccCurr and OccFcst values are printed to the screen? I notice some questions.

    (1) If you want to display two outputText on one line, you can surround them with a panelGroupLayout and set the page layout to horizontal.
    (2) I don't think that you can place an outputText in outputText one another as in the codes that you have provided.
    (3) your EL is inconsistent. What is #{row.bindings.OccCurr.inputValue} or #{line. OccCurr}? If your values are displayed, but the background color does not work, it could be the first.

    
      
        
          
          
        
      
    
    

    Kind regards
    Amélie Chan

  • MERGE TWO COLUMNS?

    Hi, I asked about my database, as follows,

    < pre >
    SELECT
    C.LKP_ID ID, D.LKP_ID ID, C.ROOT_CAUSE_CODE CODE, D.PART_DISPOSTN_DESC CODE ACE ACE ACE
    Of
    (
    SELECT DISTINCT
    A.LKP_ID AS LKP_ID
    D.PART_CNDTN_CD as ROOT_CAUSE_CODE
    C.LKP_NM as ROOT_CAUSE_DESC
    A.CREATED_DT AS OD_CREATED_DATE
    A.UPDATED_DT AS OD_LAST_UPDATED_DATE
    CREATED_DATE AS CURRENT_TIMESTAMP,
    LAST_UPDATED_DATE AS CURRENT_TIMESTAMP
    OF FWOWNER. CLM_LKP_VALUE A, FWOWNER. CLM_LKP_USAGE B, FWOWNER. CLM_LKP_VALUE_LANG C.
    IWOWNER. WC_CLM_SRVC_PART D
    WHERE B.LKP_USED_AS IN ('RR_CAUSAL_PART_CNDTN_CODE')
    AND A.LKP_REF BETWEEN B.LKP_REF
    AND B.LKP_REF + '.' 99999 and A.LKP_ID = C.LKP_ID
    AND C.LANG_CD = 'ENG_USA. '
    AND A.LKP_LVL = 3
    and D.PART_CNDTN_CD = A.LKP_VALUE
    ) C

    CROSS JOIN

    (
    SELECT DISTINCT
    A.LKP_ID AS LKP_ID
    D.PART_DISPOSTN_CD as PART_DISPOSTN_CODE
    C.LKP_NM as PART_DISPOSTN_DESC
    A.CREATED_DT AS OD_CREATED_DATE
    A.UPDATED_DT AS OD_LAST_UPDATED_DATE
    CREATED_DATE AS CURRENT_TIMESTAMP,
    LAST_UPDATED_DATE AS CURRENT_TIMESTAMP
    OF FWOWNER. CLM_LKP_VALUE A, FWOWNER. CLM_LKP_USAGE B, FWOWNER. CLM_LKP_VALUE_LANG C.
    IWOWNER. WC_CLM_SRVC_PART D
    WHERE B.LKP_USED_AS IN ('rr_parts_disposition')
    AND A.LKP_REF BETWEEN B.LKP_REF
    AND B.LKP_REF + '.' 99999 and A.LKP_ID = C.LKP_ID
    AND C.LANG_CD = 'ENG_USA. '
    AND A.LKP_LVL = 3
    and D.PART_DISPOSTN_CD = A.LKP_VALUE
    ) D

    < / pre >

    which gave rise to:


    < pre >
    ID CODE ID CODE
    ----- ----- ------- ----------
    25768 28225 REVAMPED CP01
    25771 28225 CP04 REVISED
    25774 28225 REVISED CP07
    25777 28225 CP10 REVISED
    25778 28225 REVAMPED CP11
    25779 28225 REVAMPED CP12
    25780 28225 REVAMPED CP13
    25781 28225 REVAMPED CP14
    25783 28225 REVAMPED CP16
    25785 28225 REVAMPED CP18
    25786 28225 REVAMPED CP19
    25788 28225 REVAMPED CP21
    25789 28225 REVISED CP22
    25790 28225 REVAMPED CP23
    25793 28225 REVAMPED CP26
    25795 28225 REVISED CP28
    25796 28225 REVAMPED CP29
    25797 28225 REVAMPED CP30
    25798 28225 REVISED CP31
    25799 28225 REVAMPED CP32

    20 response (s) selected [extract metadata: 0/ms] [extract data: 0/ms]

    < / pre >

    I need to merge the two ID and Code that can bring 21 records, how to do this, please help me



    Concerning
    Naren.

    Hi, Naren,

    Whenever you have a problem, it helps if you pst a small example data (CREATE TABLE and INSERT statements, elevenat columns only) and the results you want from this data.

    I suspect you want to do something like this:

    SELECT  A.LKP_ID          AS ID
    ,     D.PART_CNDTN_CD          as CODE
    FROM     FWOWNER.CLM_LKP_VALUE          A
    ,     FWOWNER.CLM_LKP_USAGE          B
    ,     FWOWNER.CLM_LKP_VALUE_LANG      C
    ,     IWOWNER.WC_CLM_SRVC_PART     D
    WHERE     B.LKP_USED_AS          IN ( 'RR_CAUSAL_PART_CNDTN_CODE'
                           , 'rr_parts_disposition'
                           )
    AND     A.LKP_REF          BETWEEN     B.LKP_REF
                        AND     B.LKP_REF + .99999     -- No quotes
    and     A.LKP_ID          = C.LKP_ID
    AND     C.LANG_CD          = 'ENG_USA'
    AND     A.LKP_LVL          = 3
    and      A.LKP_VALUE          = CASE
                             WHEN  B.LKP_USED_AS     IN ( 'RR_CAUSAL_PART_CNDTN_CODE')
                             THEN  D.PART_CNDTN_CD
                             WHEN  B.LKP_USED_AS     IN ('rr_parts_disposition')
                             THEN  D.PART_DISPOSTN_CD
                          END
    ;
    

    or maybe a UNION instead of a join.

    Published by: Frank Kulash, February 9, 2010 09:08
    Revised the last condition.

  • Single line based on two columns and a single column

    Dear members,

    I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.

    create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));

    insert into values addr ('bob', 'james', 1');
    insert into values addr ('bob', 'james', 1');

    insert into values addr ('harry', 'bert', ' 1');
    insert into values addr ('jimmy', 'bert', ' 1');

    insert into values addr ('sam', 'mac', '1');
    insert into values addr ('sam', 'Knight', '1');

    insert into values addr ('tom', 'sand', '1');
    insert into values addr ("cat", "mud", "1");


    The query output must contain 3 lines.

    Bob - james
    Harry - bert or jimmy - bert [or the other of them], but not both
    -Mac or sam - Sam Knight [or the other of them], but not both
    Tom - sand
    Cat - mud

    SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...

    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>
    
  • convert the column values to a single line...

    I have to return the column values to a single line separated by commas.
    If the nulls in the column just ignore without a comma.
    Here is one for example. There are three values and two NULL values in the table
    SQL> select ID from temp_fa;
    ID
    -----
    
             1
             2
    
             3
    
             5
    
    6 rows selected.
    
    
    I am expecting an output as 1,2,3,5
    Help, please

    There is always more than one title in the Oracle world ;)
    You can use the TRIM, for example (same configuration as your example):

    hoek&XE>  create table t as select level col  from dual connect by level <= 6;
    
    Tabel is aangemaakt.
    
    hoek&XE> update t set col = null where col in (1,3,5);
    
    3 rijen zijn bijgewerkt.
    
    hoek&XE> select * from t;
    
           COL
    ----------
    
             2
    
             4
    
             6
    
    6 rijen zijn geselecteerd.
    
    hoek&XE> select ltrim(sys_connect_by_path(col, ','), ',') output
      2  from  ( select col
      3          ,      row_number() over (order by col) rn
      4          from   t
      5        )
      6  where connect_by_isleaf=1
      7  start with rn=1
      8  connect by rn = prior rn+1;
    
    OUTPUT
    -------------------------------------------------------------------------------------------------------------
    2,4,6,,,
    
    1 rij is geselecteerd.
    
    hoek&XE> select trim ( both ',' from sys_connect_by_path(col, ',')) output
      2  from  ( select col
      3          ,      row_number() over (order by col) rn
      4          from   t
      5        )
      6  where connect_by_isleaf=1
      7  start with rn=1
      8  connect by rn = prior rn+1;
    
    OUTPUT
    -------------------------------------------------------------------------------------------------------------
    2,4,6
    
    1 rij is geselecteerd.
    
  • Check the values in two columns, in the affirmative, then generate an error

    Oracle 10g version

    Hi gurus

    I'm test1 table and it contains several columns, my requirement I want to create some sort of conditions or constraints before inserting data into test1, it will check that application_id or APPLICATION_TYPE_CD contains no values in the two columns...

    I appreciate your advice. Thank you

    / / DESC test1

    APPLICATION_ID NUMBER (10)

    DATE OF APPLICATION_DT

    APPLICATION_TYPE_CD VARCHAR2 (10)

    DATE OF CREATED_DT

    Concerning

    MIT

    You need a check as a constraint:

    ALTER table test1 add constraint only_one

    check ((application_id n'est pas null et application_type_cd est null) or)

    (application_id is null and application_type_cd is not null))

    John

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • How do to convert two points separated in several lines in the report, the column values

    Hi all

    I want to display two separate points of values in a column, in a row of multi in report.

    For example I have a Column1 in an array with the value 'A', column2 has the value "1".

    I want to show in a report of three lines using these two columns as

    Column1 Column2
    A 1
    B 1
    A s

    Here's one way:

    SQL> create table test (col1 varchar2(20), col2 number);
    
    Table created.
    
    SQL> insert all
      2    into test values ('A:B:C', 1)
      3    into test values ('Dg:Ezs', 2)
      4  select * from dual;
    
    2 rows created.
    
    SQL> select
      2    t.col2,
      3    regexp_substr(t.col1, '\w+', 1, t2.column_value) c1
      4  from test t,
      5    table(cast(multiset(select level
      6                        from dual
      7                        connect by level <= length(t.col1) - length(replace(t.col1, ':', '')) + 1
      8                       ) as sys.odcinumberlist )) t2
      9  order by 2, 1;
    
          COL2 C1
    ---------- --------------------
             1 A
             1 B
             1 C
             2 Dg
             2 Ezs
    
    SQL>
    

    Published by: little-foot 31 January 2012 10:13

  • Merge multiple columns into a single column?

    Hello

    I need to perform queries dynamically and the return values. I need to retrieve the values of the queries in a single column only by concatenating multiple columns. I can't use the PL/SQL in my scenario.
    is it possible to run a query and the result will be extracted in a single column (multiple column values must be concatenated)?

    Thank you
    Raja.
    SELECT rtrim(extract(xmltype(REPLACE(column_value,'
    

    Check this box... Copy it directly to this

    Ravi Kumar

  • Should be changed to two full pages in a single page with two columns

    I have a schedule that is formatted to 8 1/2 x 11 size.  I want to change this option to display two pages on one page into two columns?  How can I do this?  Thanks in advance.

    It's extremely well beyond what is possible or even imaginable for PDF editing. Redo in Word; You can use export as Word, copy paste and export the images as tools to do this. Then again the PDF file.

  • The combination of two columns in a single

    Hi guys,.

    Is it possible for a query to combine two columns into one? For example, lets say I have the following query:

    SELECT ID, FIRST_NAME, LAST_NAME
    EMPLOYEES

    I want the output to have two columns: one that contains the ID and the other containing name followed by a space followed by LAST_NAME. I know how to do this outside the query using coldfusion, but it save me a lot of work if there is some way that the query could do for me.

    Yes but the operand of concatenation varies somewhat from a database
    management system to the other.

    In Oracle, it would look this IIRC.

    SELECT ID, FIRST_NAME. ' ' || LAST_NAME AS FULL_NAME
    EMPLOYEES

  • retriving of unique records on two columns

    Hello world


    Using sql query, that he must retrieve unique records on two columns.

    Example of table source: raster columns [uwi, well_no]

    Examples of data below


    UWI well_no

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

    1 988311

    1 988311

    1 1032662

    1 1032662

    2 103

    2 103

    2 103

    3

    3 104

    3 104

    3 104

    4 106

    4 107

    4

    4 108

    For a given

    UWI: 1 there are 4 well_no which is having two distinct values where these documents I need to go get

    UWI: 2 there are 3 well_no, all 3 well_no contains the same value as (103) Consequently, these documents should not seek

    UWI: 3 there are 4 well_no (1 null and 3 values are the same (104)] where these records should not seek.)

    UWI: 4 there are 4 well_no which is to have three separate with a single value zero so these 4 files, I need to get.

    output:

    UWI well_no

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

    1 988311

    1 988311

    1 1032662

    1 1032662

    4 106

    4 107

    4

    4 108

    Thank you

    Jery

    Hi, Michel,.

    Whenever you have a question, please post CREATE TABLE and INSERT statements for your sample data, so people who want to help you can recreate the problem and test their ideas.

    Format your message so that it is easy to read and understand.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    Maybe you want something like this, which shows information about the jobs that have deptnos 2 or more not NULL:

    WITH got_cnt AS

    (

    SOME jobs, deptno

    , ACCOUNT (SEPARATE deptno) RESUMED (work PARTITION) AS cnt

    FROM scott.emp

    )

    SOME jobs, deptno

    OF got_cnt

    WHERE cnt > 1

    ;

  • unique index on two columns

    Hi all
    I want a unique index on two columns, but when I try this it will show me
      1  CREATE UNIQUE INDEX sale_order_no
      2*   ON sale_order (sale_order_no, season_year)
    SQL> /
      ON sale_order (sale_order_no, season_year)
         *
    ERROR at line 2:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    I want to do not overlap with the combination of these two

    Plaese Guide
    Thanks and greetings
    Vikas

    You would this behavior if SALE_ORDER_NO has NULL values. If it contains NULL values, a unique single-column index will succeed but an index unique multi-column will fail when it finds duplicates in SEASON_YEAR.

    See:

    SQL> create table dummy_objects (object_id  number, object_owner varchar2(30), object_name varchar2(30));
    
    Table created.
    
    SQL> insert into dummy_objects values (0,'HEMANT','TABLE_A');
    
    1 row created.
    
    SQL> insert into dummy_objects values (1,'HEMANT','TABLE_B');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_1');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_2');
    
    1 row created.
    
    SQL> create unique index dummy_objects_u1 on dummy_objects(object_id);
    
    Index created.
    
    SQL> drop index dummy_objects_u1;
    
    Index dropped.
    
    SQL> create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner);
    create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner)
                                            *
    ERROR at line 1:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    
    SQL>
    

    Hemant K Collette
    http://hemantoracledba.blogspot.com

  • queries mergeing two in single query? Thank you!!!

    Hello gurus,

    How to merge below two queries in a single request. All the I'm trying to do is get the acc_office_id and the pay_office_id... We want it in two different columns because the office for access and compensation IDs are in the same column. .so I m try to divide it into two columns.

    Any help is greatly appreciated... Thank you very much!!!



    -request for VAC office_id

    Select acc.cust_id cust_id,
    RO.office_id acc_office_id,
    ACC.office_cd office_cd,
    ACC.type_cd type_cd
    of refoff ro,.
    (select distinct f.cust_id cust_id,
    f.type_cd type_cd,
    f.office_cd office_cd
    cutomer p,
    Office f
    where p.cust_id = f.cust_id
    and f.type_cd in ('ACCT')) VAC
    where acc.office_cd = ro.office_cd;


    -request for pay office_id


    Select bill.cust_id cust_id,
    RO.office_id acc_office_id,
    Bill.office_cd office_cd,
    Bill.type_cd type_cd
    of refoff ro,.
    (select distinct f.cust_id cust_id,
    f.type_cd type_cd,
    f.office_cd office_cd
    cutomer p,
    Office f
    where p.cust_id = f.cust_id
    and f.type_cd in ("wages")) pay
    where pay.office_cd = ro.office_cd;

    Hello

    SELECT       c.cust_id
    ,       MAX (CASE WHEN c.type_cd = 'part1' THEN o.office_cd END)     AS par1_offc_id
    ,       MAX (CASE WHEN c.type_cd = 'part2' THEN o.office_cd END)     AS par2_offc_id
    ,       MAX (CASE WHEN c.type_cd = 'part3' THEN o.office_cd END)     AS par3_offc_id
    FROM       cust_office     c
    JOIN       office     o     ON     c.office_cd     = o.office_id
    GROUP BY  c.cust_id
    ;
    

    The output I get from your sample data is a little different from what you have posted:

    CUST_ID    PAR1_OFFC_ID    PAR2_OFFC_ID    PAR3_OFFC_ID
    ---------- --------------- --------------- ---------------
    2001       10              10              10
    2003       12              14
    2002       11              11              12
    2004       13              13              15
    

    If the differences are not due to errors in your message, explain how you get correct results.

Maybe you are looking for