How to divide values to several columns

Hi
I have a table including values that I want to display in 5 columns.
Table structure is:
Use_id number (primary key)
target id number
code number
Values in a table are:
1 234 22
2 345 23
3 564 24
4 634 25
5 345 24
6 545 22
7 234 23
8 634 23
I want to select (display) the values like:
target_id code22 code23 code24 code 25
234 22 23
345 23 24
564 24
634 23 25
545 22
Is it possible to create a view for that purpose?
Message was edited by:
user545002

If you know the different possible codes in advance, you can try something else like below :
SQL> create table mytable (Use_id number primary key,
  2  target_id number,
  3  code number);
Table created.
SQL>
SQL> insert into mytable
  2  select 1, 234, 22 from dual union all
  3  select 2, 345, 23 from dual union all
  4  select 3, 564, 24 from dual union all
  5  select 4, 634, 25 from dual union all
  6  select 5, 345, 24 from dual union all
  7  select 6, 545, 22 from dual union all
  8  select 7, 234, 23 from dual union all
  9  select 8, 634, 23 from dual ;
8 rows created.
SQL>
SQL> create or replace view myview
  2  as select target_id,
  3            max(decode(code,22,code)) code22,
  4            max(decode(code,23,code)) code23,
  5            max(decode(code,24,code)) code24,
  6            max(decode(code,25,code)) code25
  7  from mytable
  8  group by target_id;
View created.
SQL>
SQL> select * from myview;
TARGET_ID     CODE22     CODE23     CODE24     CODE25
       234         22         23
       345                    23         24
       545         22
       564                               24
       634                    23                    25
SQL> Nicolas.

Similar Messages

  • How to retrieve value of one column to other in Apex using Javascript

    Hi all,
    Can any one help me in solving this problem.
    How to send a value from one column to another column using javascript in Apex. I heard that we can use onChange().
    My requirement is,
    I have a column(Varchar2) in form where i need to enter a value and the data need to be sent to another column(Number) when i press apply changes.
    ex: if i enter a value say 1/3 or 1/4 or 1/3*1/6
    the result should be entered in the other column.
    Message was edited by:
    Raman

    Try something like
    html_GetElement('P1_ITEM2').value = eval(html_GetElement('P1_ITEM1').value);

  • How to set value of a column in report region

    Hi,
    I have a report region based on a query.In this my first column is selectlist "select row" having to values "yes" & "No".
    I have two buttons on top of the region "Check all" and "uncheck all".
    My requirement is when I click check all button all rows corresponding to "select row" column gets selected to Yes and when I click No all rows gets selected to "No".
    Thanks
    Vikram

    Actully I want to set the value of a column in report region.
    There are replies in the forum but in those the item is in form but not in the report region.
    I am generating report region by using htmldb_item.selectlist and i dont know how to set value in these type of items.

  • How to calculate value from perticular column and row in pivot table

    Hi all,
    I am having following pivot table.
    Country
    A
    B
    C
    D
    F
    G
    H
    J
    K
    L
    M
    Grand Total
    Canada
    1
    1
    3
    3
    12
    14
    13
    97
    China
    8
    4
    3
    19
    India
    2
    47
    448
    176
    395
    3656
    1964
    1360
    8077
    USA
    1545
    352
    380
    26
    10
    4
    8
    32
    2054
    1023
    758
    4624
    UK
    12
    19
    13
    23
    33
    298
    Grand Total
    1545
    352
    381
    29
    72
    474
    184
    427
    5743
    3028
    2167
    13114
    Now I want sum of Columns A, B, C, K, M where Country = India in one field.
    and sum of D, F, g in another field. and sum of remainig columns in another field.
    How can i get sum of values with some where condition in pivot table.
    Thanks,

    Hi Michael,
    Following is the representation which i want
    CouRntry
    ROW LABLES
    A
    B
    C
    Total of
    ABC
    F
    G
    Total
    Of FG
    J
    K
    L
    TOTAL
    of JL
    Grand
    Total
    Canada
    1
    1
    3
    3
    12
    14
    13
    97
    China
    8
    4
    3
    19
    India
    2
    47
    448
    176
    395
    3656
    1964
    1360
    8077
    USA
    1545
    352
    380
    26
    10
    4
    8
    32
    2054
    1023
    758
    4624
    UK
    12
    19
    13
    23
    33
    298
    Grand Total
    1545
    352
    381
    29
    72
    474
    184
    427
    5743
    3028
    2167
    1
    Also if i get sum how can i add a column in between of the fields.
    Thanks

  • How to concatinate values of two columns and update into another column

    There is a table : TEST contains three columns - Column1 , Column2 , Column 3
    Column1 contains values - (1,2,4)
    Column2 contains values : (a,b,c)
    Column 3 is empty .
    Target : Values in column 3 should be (1a,2b,4c)
    Need to achieve this through procedure .

    Paul if i want to concatenate two strings or alpha numeric characters from 2 fields and display in the third field,Will this code be able to do that?

  • How to group values in a column in ALV Grid

    Hi ,
        i have got a report layout like below.
          1   4
          1   5
          1   6
          2   7
          2   8
          2   8
    now i want to group the 1st column like below
         1  4
            5
            6
         2  7
            8
            8
      How can i get this in ALV grid display.....pls help me out if any of u have got a sample code.

    Hi,
    Here is a sample program which shows how to do sorting.
    report zsudheer
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    <b>data: sort     type slis_t_sortinfo_alv.</b>
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          matkl type mara-matkl,
          labor type mara-labor,
          brgew type mara-brgew,
          maktx type makt-maktx,
          end of imara.
    * Selection Screen
    selection-screen begin of block b1 with frame title text-001 .
    select-options: s_matnr for imara-matnr .
    selection-screen end of block b1.
    start-of-selection.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      select  mara~matnr mara~matkl mara~labor mara~brgew makt~maktx
                into corresponding fields of table imara
                  from mara
                   inner join makt
                     on mara~matnr = makt~matnr
                        where mara~matnr in s_matnr
                          and makt~spras = sy-langu.
    endform.
    *  WRITE_REPORT
    form write_report.
      perform build_field_catalog.
      <b>perform build_sort.</b>
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_sort     = sort
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      fc_tmp-col_pos    = 2.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Group'.
      fc_tmp-fieldname  = 'MATKL'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '12'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Sort Group'.
      fc_tmp-fieldname  = 'LABOR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '12'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Gross Weight'.
      fc_tmp-fieldname  = 'BRGEW'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '12'.
      fc_tmp-do_sum     = 'X'.
      fc_tmp-col_pos    = 4.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Description'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-col_pos    = 5.
      append fc_tmp to fieldcat.
    endform.
    *       FORM build_sort                                                *
    form build_sort.
      data: tmp_sort type line of slis_t_sortinfo_alv.
      clear sort. refresh sort.
    <b>  clear tmp_sort.
      tmp_sort-fieldname = 'MATKL'.
      tmp_sort-tabname   = 'IALV'.
      tmp_sort-up        = 'X'.
      append tmp_sort to sort.
      clear tmp_sort.
      tmp_sort-fieldname = 'LABOR'.
      tmp_sort-tabname   = 'IALV'.
      tmp_sort-up        = 'X'.
      tmp_sort-subtot    = 'X'.
      append tmp_sort to sort.</b>
    endform.
    Regards,
    Sudheer

  • How to split values across the columns

    Hi,
    I have a dataset as follow
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ROWSET>
    - <ROW>
    <fm_firmnum>0054</fm_firmnum>
    </ROW>
    - <ROW>
    <fm_firmnum>0053</fm_firmnum>
    </ROW>
    - <ROW>
    <fm_firmnum>0055</fm_firmnum>
    </ROW>
    </ROWSET>
    Now, I have created a rtf template and would like to make the table look like the following under this circumstances
    - If the rows (row count, but I dont' know how to do row count in BIP) mod 2 = 1 then put it in the left column of the table
    - If the rows mod 2 = 0 then put it in the right column of the table.
    Hence the table should look like this as the outcome
    fm_firmnum | fm_firmnum
    0054 | 0053
    0055 |
    Any idea on how to do it? Many thx
    Rgds,
    Raymond

    Hi Raymond,
    The rowcount can be known using position() syntax:
    so your logic can be achieved using the following way:
    Col1 Col2
    <?if:position() mod 2 =1?><fm_firmnum><?end if?> <?if:position() mod 2 =0?><fm_firmnum><?end if?>
    Keep this on one form field <?if:position() mod 2 =1?><fm_firmnum><?end if?>
    and keep this in 2nd form field <?if:position() mod 2 =0?><fm_firmnum><?end if?>
    Best Regards,
    Mahi
    Edited by: BIP Learner on Jul 19, 2009 10:44 AM

  • How to get value in previous column and another row from Matrix with Custom Code?

    I want to calculate the value of tb_Open and tb_Close. I try to use custom code for calculate them. tb_close is correct but tb_Open is not correct that show value = 0 .
    This is example report:
    * I have 2 Dataset , Dataset1 is all data for show in my report. Dataset2 is only first Open for first month
    * First value of Open is item field in Dataset2 and this value only for first month (january). But for other month Open value get from Close in previous month.
    Detail for Red number:
    1. tb_Open -> tb_Close in previous month but first month from item field in Dataset2
    expression =FormatNumber(Code.GetOpening(Fields!month.Value,First(Fields!open.Value, "Dataset2")))
    2. tb_TOTAL1 group on item_part = 1
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)))
    3. tb_TOTAL2 group on item_part = 3 or item_part = 4
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) + ReportItems!tb_TOTAL1.Value )
    4. tb_TOTAL3 group on item_part = 2
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) - ReportItems!tb_TOTAL2 .Value)
    5. tb_Close -> calculate from tb_TOTAL3 - tb_Open
    expression =FormatNumber(Code.GetClosing(ReportItems!tb_TOTAL3.Value,ReportItems!tb_Open.Value))
    My custom code:
    Dim Shared prev_close As Double
    Dim Shared now_close As Double
    Dim Shared now_open As Double
    Public Function GetClosing(TOTAL3 as Double,NowOpening as Double)
        now_close = TOTAL3 + NowOpening
        prev_close = now_close
        Return now_close
    End Function
    Public Function GetOpening(Month as String,NowOpen as Double)
        If Month = "1" Then
            now_open = NowOpen
        Else    
            now_open = prev_close
        End If
        Return now_open
    End Function
    Thanks alot for your help!
    Regards
    Panda A

    Looks okay to me.
    Perhaps the variables should be declared as public (?)

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to use Default value in a column in Tabular form in insertion or upda

    Hello,
    I am trying to use Default values so that user need not have to enter data, but when I select default type and put a default value, I see an error message, if I try to add a new row.
    How can I use a default value in a Column in a Tabular Form?
    Gouri
    Edited by: user1046395 on Apr 3, 2009 9:58 AM

    Gouri,
    You can just simply edit to each column's report attribute. For example,
    To set default date,
    Default Type: PL/SQL Expression of Function
    Default: sysdate
    To set default text,
    Default Type: PL/SQL Expression of Function
    Default: *'CLERK'*
    If you still have an error, what is the error message?
    Ittichai

  • "How to get distinct values of sharepoint column using SSRS"

    Hi,
        I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
    <Query>
       <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
       <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
          <Parameters>
             <Parameter Name="listName">
                <DefaultValue>{GUID of list}</DefaultValue>
             </Parameter>
             <Parameter Name="viewName">
                <DefaultValue>{GUID of listview}</DefaultValue>
             </Parameter>
             <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
             </Parameter>           
          </Parameters>
       </Method>  
    <ElementPath IgnoreNamespaces="True">*</ElementPath>
    </Query>
    By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
    Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
              I would really appreciate if anyone can help me out with this.
    Thanks,
    Sam.

    Hi Sam,
    By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
    In this case, we could use the custom code to get distinct records.
    Here are the detailed steps:
    1.         Create a hidden parameter that gets all the records in one field.
    Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
    2.         Create a function that used to remove the duplicate records.
    Here is the code:
    Public Shared Function RemoveDups(ByVal items As String) As String
    Dim noDups As New System.Collections.ArrayList()
    Dim SpStr
    SpStr = Split(items ,",")
    For i As Integer=0 To Ubound(Spstr)
    If Not noDups.Contains(SpStr(i).Trim()) Then
    noDups.Add(SpStr(i).Trim())
    End If
    Next
    Dim uniqueItems As String() = New String(noDups.Count-1){}
    noDups.CopyTo(uniqueItems)
    Return String.Join(",", uniqueItems)
    End Function
    3.         Create another parameter that will be used for filtering the maindata.
    Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
    And the default value to be the value you what such as the first value:
    =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
    4.         Go to the main dataset. Open the property window of this dataset.
    5.         In the “Filters” tab, set the filter to be:
    Expression: <The field to be filter>
    Operator: =
    Value: =Parameters!Region.Value
    The parameter “Region” should be the parameter we created in the step3.
    Now, we should get distinct values of SharePoint columns.
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jin
    Jin Chen - MSFT

  • How to get all the values in one column of a JTable

    How to get all the values in one column of a JTable as a Collection of String.
    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column.

    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column. You could always write a custom TableModel that stores the data in the format you want it. It would probably be about 50 lines of code. Or you could write a loop in 3 lines of code. I'll let you decide which approach you want to take.

  • How to represent multiple values in one column

    Hi,
    I need some help in designing a schema for this problem.
    I have :
    - 4 domains
    - In each domain there will be many groups
    - users belong to multiple groups in multiple domains
    Eg.
    user1 might be in groups g1, g2 and g3 in domains d1, d2
    In a text file I represent it like this:
    user1 | d1 | g1,g2,g3
    user2 | d2 | g1, g2
    etc.,
    How do design a schema for this. I don't like the idea of having comma
    separated values in columns.
    Thanks.

    Good instincts. You don't want to have comma-separated values in a column, that violates basic normalization rules.
    You would probably want something like this
    CREATE TABLE usr (
      user_pk
      user_id
    CREATE TABLE grp (
      group_pk
      group_id
    CREATE TABLE domain (
      domain_pk,
      domain_name
    CREATE TABLE domain_group (
      domain_pk,
      group_pk
    CREATE TABLE user_group (
      user_pk,
      group_pk
    )where you create separate tables that map different things to each other. domain_group shows which groups are associated with a particular domain, user_group shows which users are associated with a particular group.
    Justin

  • How can I get the value of "Warehose" column in a form

    How can I get the value of "Warehouse" column in the form below (I mean what table that contain this value):
    Production Supervisor >> Batches >> (Button) Material Details >> (Button) Line Allocations
    Well, for more clearly! My problem is I must have the Unit Cost of Items, so I've got it in the cm_cmpt_dtl (table), but if I want to, I must create a relation that require 2 filed, they're Item_ID and Whse_Code.
    There's no problem with Item_ID, but Whse_Code seem to be the Mission Impossible (hix, I hate that film!!!!)
    I wonder if It was right to post this topic here. But anyway I just post my question here, hope I could get some help.

    wow, many, many, many.... and many thanks!
    Just add a tiny modify to check out the Batch_type
    doc_id = (select batch_id from gme_batch_header where batch_no='&batch_number' and batch_type = 0)
    Because the batch_no can be duplicated as we also create Batch and Filrm Planned Order.
    Many thanks for your support!
    P/S: Sorry for my terrible English :P

  • How do you lookup multiple values in different columns based on variable criteria?

    Essentially, I'd like to be able to do a Vlookup but instead of searching for one value only, search for multiple values in separate columns. A smaller version of my current spreadsheet as an example...
    Attack Type ->
    Fire
    Water
    Grass
    Fire
    1/2x
    2x
    1/2x
    Water
    1/2x
    1/2x
    2x
    Grass
    2x
    1/2x
    1/2x
    Fire/Water
    1/4x
    1x
    1x
    Fire/Grass
    1x
    1x
    1/4x
    Grass/Water
    1x
    1/4x
    1x
    The headers are the attack types and the list of types to the left are the receiving Pokemon. Fire does half damage (1/2x) to fire types, Water does double damage (2x) to fire types, etc. I'd like to be able to search for specific damages for each type. For example, I'd like to find a Typing that recieves half (1/2x) damage from Fire-type attacks but also recieves double (2x) from Grass-type attacks. I do want more than just two search criteria though seeing as the actual table is much, much larger.
    I've tried assigning number values to each damage multiplier and then merging all of them together for a specific typing and doing a VLOOKUP based on checkboxes determining what damage multiplier I want in a few specific types, the rest being filled in to the standard of 1x but the result isn't correct most of the time.

    Hi Mitchell,
    VLOOKUP can be set for accept either an 'exact match' or a 'close match'.  Your 17 digit 'number' is actually a 17 character text string (Numbers can handle numbers to a precision of only 15 places). Provided all 17 digits are present, sorting should be the same as for numerical values—the leftmost character is the most significant.
    As a text string, your 'number' is sorted/evaluated alphabetically. A 'close match' accepts the 'largest value that is less than or equal to the search value'.
    If your search term is 000200000 (a 9 character string), several 'wrong' answers will fit the 'close match' criteria, including all of those listed below:
    000200000 (the 'correct' match)
    0000xxxxx (x may be any of the three acceptable values)
    0001xxxxx (x may be any of the three acceptable values)
    The main problem here is that digits in a number (or characters in a text string) have decreasing significance related to their distance from the beginning of the string/number. You want a search in which each character has the same significance as each of the others when compared to the search key. To do that, you need to compare each character in the search string with the character in the same position in the similar string for each type of Pokemon, then take a count of the matches or a sum of the differences.
    Here's one approach:
    Column A contains labels.
    Column B, the 17 digit search term, created in whatever manner you wish, and the similar 17 digit string for each of the characters.
    Columns C through S contains a formula that detines, using subtraction, the difference between each digit of the search term and the corresponding digit of each character's profile.
    Column C uses SUM() to calculate the total of columns C to S for each row.
    T1 uses =MIN(T) to calculate "least different" profile.
    Column A is a Header column; Row 1 is a Header row.
    Formulas:
    C2, and filled right to S2, then down to the last row of data:
    =ABS(MID($B$1,COLUMN()-2,1)-MID($B2,COLUMN()-2,1))
    T1: =MIN(T)
    T2, and filled down column T: =SUM(C2:S2)
    The conditional formatting rule set for all body cells in column T is shown below the table.
    This may be enough to get you started. Formulas can be tweaked to produce results more closely matching what you're looking for, if necessary.
    Regards,
    Barry

Maybe you are looking for

  • AFP login via Kerberos from 10.5 clients to 10.4 server broken

    I don't know if this is connected to the problem laid out by William W. Higgins in [Open Directory or LDAP Problem with 10.5 Client and 10.4 Server|http://discussions.apple.com/thread.jspa?threadID=2163645&tstart=0]. The symptoms are... somewhat diff

  • Playing video from iPhone 4 on PC

    I wonder if anyone has any suggestions for a fix. I have been able to transfer both pictures and video from my phone to my PC without problem. The videos have the quicktime thumbnail but if i try to play it with quicktime the sound is ok but all I ge

  • Script to find the service and manage its state

    We have a service that runs with different names on different machines like Bomgar-scadsadccd, Bomgarsdscchfn, Bomgarscnkfkdk So, here we need to write a VB script that will find this service with partial name "Bomgar" and check it's status like 1) N

  • Client Session Not getting expired in OBI EE 10.1.3.4.1

    Hi All, I haave placed the below tag in the instanceconfig.xml file, but the client session is not getting expired. Can you please help me on the same. Our test environment OBI is enabled with the Site minder SSO. <ClientSessionExpireMinutes> 60</Cli

  • Communication between BI70 and EP70

    Dears, After make the communication using SSO between BI70 (stack abap) and EP70 (stack java) we try execute a query using Bex, call the EP, but appear error message below; Portal runtime error. An exception occurred while processing your request. Se