Display a single field in one table as 2 colums

Hi all..,
I am using oracle 8.1.5.,I have two tables table 1 and table 2, i have one single field
as name how to display it in 2 columns....
here i have given the thing,,,,,
create table table1(user_id int,name varchar(50))
create table table2(host_id int,user_id int)
/* here host_id refers to the user_id in the table1 */
insert into table1 values(1,'Arul')
insert into table1 values (2,'Bala')
insert into table1 values(3,'Karthik')
insert into table1 values(4,'Chandru')
insert into table1 values(5,'Pandi')
insert into table1 values(6,'Sathya')
/* here user_id 1,2 are the hosts, so i assign the users to the host in the table2 as follows*/
insert into table2 values(1,3)
insert into table2 values(1,4)
insert into table2 values(2,5)
insert into table2 values(2,6)
/* here host_id refers to the user_id in the table1 */
now i want to diaplay the host_name and user_name as follows..
i.e.,
=========================
host_name | user_name |
=========================
| |
Arul | Karthik |
Arul | Chandru |
Bala | Pandi |
Bala | Sathya |
==========================
how to do this...
null

You can get the result by this sql as below,
select t1_1.name || '|' || t1_2.name || '|'
from table2 t2
inner join table1 t1_1 on t2.host_id = t1_1.user_id
inner join table1 t1_2 on t2.user_id = t1_2.user_id;You would better post to the 'SQL and PL/SQL forum' in next time.

Similar Messages

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • To Display a date field in TSTCT table

    Dear Experts,
    Recently we got a request to have a date field in TSTCT table. So, that when ever the new transaction is created the date will automatically display  in TSTCT table. Now there is only three fields in the table. There is no further settings to regarding the display of date field. Is there any possible cases/BADI's which helps to display the Date field in TSTCT Table. Please help me with possible solutions.
    Thanks in advance, Regards,
    Harsha.

    Dear Eswara,
    It is not possible adding field through BADI or exit. But you go into /nSE11 for this table and go to Technical Settings, if the check box 'Log Data Changes' is set then you may be able to display a log of changes made to entries in this table using /nSCU3.
    Regards,
    Abbas.

  • How to change the screen element of a single field in a table control

    Hi Gurus,
    I want to change the screen element of a single field (or the whole row) in a table control according to a condition.
    I have 2 columns in the table control. One is an input column and one output only. When user enters values into the input column, they need to be compared against the values in the other column, and if there is a discrepancy, the row where the discrepancy is needs to be highlighted.
    I have tried the following code which highlights the whole column ...
    CONTROLS: TC_ZVOYG_BINS TYPE TABLEVIEW USING SCREEN 0500.
    DATA: wa_tc_zvoyg_col LIKE LINE OF TC_ZVOYG_BINS-cols.
      LOOP AT G_TC_ZVOYG_BINS_ITAB
               INTO G_TC_ZVOYG_BINS_WA.
        if G_TC_ZVOYG_BINS_WA-zdelivery_bin ne G_TC_ZVOYG_BINS_WA-zactual_bin.
          loop at screen.
            IF screen-name = 'ZVOYG_BINS-ZACTUAL_BIN'.
              wa_tc_zvoyg_col-screen-intensified = 1.
              MODIFY tc_zvoyg_bins-cols FROM wa_tc_zvoyg_col TRANSPORTING
              screen-intensified WHERE screen-name = screen-name.
            endif.
          endloop.
        endif.
      endloop.
    And also the following code which makes no change ...
      LOOP AT G_TC_ZVOYG_BINS_ITAB
               INTO G_TC_ZVOYG_BINS_WA.
        if G_TC_ZVOYG_BINS_WA-zdelivery_bin ne G_TC_ZVOYG_BINS_WA-zactual_bin.
          loop at screen.
            IF screen-name = 'ZVOYG_BINS-ZACTUAL_BIN'.
              screen-intensified = '1'.
              modify screen.
            endif.
          endloop.
        endif.
      endloop.
    Thanks in advance.

    Hi,
    The modification of a screen element attribute (LOOP AT SCREEN...MODIFY SCREEN) must always be done in the PBO (for a dynpro, it will be in a PBO module, i.e. declared by MODULE ... OUTPUT)
    About the loop at the internal table, it is done automatically by the system, also during the PBO, you'll find something like LOOP [AT itab] ... WITH CONTROL ...  in the PBO part of the screen flow logic (note: you may have to complete with a supplementary READ TABLE if you don't use AT itab). So you don't need an additional loop.
    Best regards
    Sandra

  • Move fields from one table to another

    Hi,
    I would like to move fields from one internal table into corresponding fields of another internal table.
    move-corresponding syntax seems only to work with structures. How do you accomplish this for internal tables? Do I have to use for loops?
    regards
    Baran

    Yes you have to use loops and move-correspoding statements unless you have all the common fields in the same order on both internal table and no different fields to the left most.
    eg:
    data: begin of itab1 occurs 0,
             field1 type i,
          end of itab1.
    data: begin of itab2 occurs 0,
             field1 type i,
             field2(1),
          end of itab2.
    do 5 times.
    itab1-field1 = sy-index.
    append itab1.
    enddo.
    itab2[] = itab1[].
    loop at itab2.
    write:/ itab2-field1.
    endloop.
    The above code would give you some idea.
    Regards,
    ravi

  • Compare two fields of one table in selection.

    Dear Experts,
    I want to compare two fields of a table and make selection according to this.
    Ex: simply i want to select the rows from table mard where mard-labst>mard-insme. Could you write me the code to make this selection.

    Yes, Thomas,
    Its working:
    Sample code:
    data: begin of itab occurs 0,
          matnr type matnr,
          ernam type ernam,
          end of itab.
    select matnr ernam
           into table itab
           from mara where brgew > mara~ntgew.
    loop at itab.
      write: itab-matnr.
    endloop.
    Or,
    Try with inner join once.
    Its working: Sample code.
    data: begin of itab occurs 0,
          matnr type matnr,
          ernam type ernam,
          end of itab.
    select p~matnr q~ernam
           into table itab
           from mara as p
           inner join mara as q
           on p~brgew > q~ntgew.
    loop at itab.
      write: itab-matnr.
    endloop.
    Thanks,
    Naveen.I

  • BI - ABAP To pick the field from One table and link with 2nd table

    Hello, I am stuck to write the correct abap code. Requirement is that My Client BMW  California require the below:
    <b>1.</b>  list of invoices (BELNR) that a has tcode = FB01 and FBVB" from Table BKPF.  Account Number field (BELNR) is there in 0fiap_4 Data source
    <b>2.</b> Now Link the above invoice Number (BELNR)  that a has tcode = FB01 and FBVB" from Table BKPF to BMW Custom Table I_BMW_WI. - Field "PAT ID" which is the cocatenation of OBJNR (Object Number), Invoice Number and Purchase Year.  where PICK only thos PAT ID where "TYPEID"  Value = "BMW" in table I_BMW_WI.
    To solve Number 1 Please fix my abap code and help me to write the Code to Solve Number 2 and Link #1 AND #2.
    Please help me soon
    Code # 1
    case I_datasource.
    WHEN '0FI_AP_4'.
    loop at C_t_data into l_s_DTFIAP_3.
    l_tabix = sy-tabix.
    clear I_BMW_WI.
    if sy-subrc = 0.
    select single * from BKPF into I_BKPF where BELNR = l_s_DTFIAP_3-BELNR.
    LOOP AT I_BKPF into I_FINAL WHERE
    Code below is not working
    (I_BKPF-TCODE = ‘FV50’) OR (I_BKPF-TCODE = ‘FB01’)
    I_FINAL-BELNR = I_BKPF-BELNR
    modify I_FINAL.
    endloop
    modify C_t_data from l_s_DTFIAP_3  index l_tabix.
    endif.
    endloop.
    endcase
    Code # 2 -
    Please help with templates.
    Thanks
    Soniya Kapoor

    Hi,
    Ad Code #1
    First of all the key for BKPF consists of:
    BUKRS, BELNR and GJAHR so I think you should use all key fields in your SELECT statement:
    select single * from BKPF into I_BKPF
    where BUKRS = l_s_DTFIAP_3-BUKRS and
          BELNR = l_s_DTFIAP_3-BELNR and
          GJAHR = l_s_DTFIAP_3-GJAHR.
    And why do you test SY-SUBRC after CLEAR ?
    Your IF statement should be after SELECT...
    And last but not least when you are using SELECT SINGLE you always get only one record so what is the purpose of LOOP statement ?
    Try following code:
    case I_datasource.
    WHEN '0FI_AP_4'.
      loop at C_t_data into l_s_DTFIAP_3.
        l_tabix = sy-tabix.
        select single * from BKPF into I_BKPF
          where BUKRS = l_s_DTFIAP_3-BUKRS and
                BELNR = l_s_DTFIAP_3-BELNR and
                GJAHR = l_s_DTFIAP_3-GJAHR.
        if sy-subrc = 0.
          if (I_BKPF-TCODE = ‘FV50’) OR
             (I_BKPF-TCODE = ‘FB01’).
            I_FINAL-BELNR = I_BKPF-BELNR
            modify I_FINAL.
          endif.
          modify C_t_data from l_s_DTFIAP_3 index l_tabix.
        endif.
      endloop.
    endcase.
    regards
    Krzys

  • Display all the fields in one screen shot

    Hi all,
    I am having 20 fields in the grid.
    but few fields are displaying in the grid and the scroll bar is existing to display other fields
    where as i need all the fields in on screen shot.
    let me know it .

    Hi ,
      One option would be to reduce the width of the fields in the catalog or manually after the data is displayed.
    Regards:
    Arun

  • Retriving single field from two tables which are unrelated

    Hi experts..
           i would like to retrieve a field say X from two database tables TAB1 and TAB2 which are unrelated . Can you give me a way to retrive the field X from TAB1 and TAB2 in a single select statement on perticular condition.
    Reward points if aswered..

    Hi,
    If the field is in two tables,you can use for all entries. But anyway two select statemetns are needed.
    If you want single select statement, try using subquery.

  • How to display the single characterstics (top one) wrt  key figure

    Hi,
    I have got a reporting issue like::
    Values in Cube-
    GL     Fiscal year/period     Doc no    Amount
    1         2004.006                 1              10000
    1          2004.006                2               15000
    1          2004.007                3                20000
    i want to show in my report as--
    1      2004.006                  1               10000
    1       2004.007                 3                20000
    i.e it should pick only the first line from cube corresponding to the 2004.006 period..

    Hi,
    You have 2 options
    1. you can create a transformation and write a starteroutine so that it takes the first record of the document number. but in practical it is not advisable because the cube contains inconsistant data and you cant develope any other reports on it.
    2. Next option is
    Step1
    You  need to write the user-exit to populate Reporting related variables in the Enhancement assignment RSR00001 and select the FM EXIT_SAPLRRS0_001 and then in the include ZXRSRU01 we need to write the code. These are helpful especially we need to derive any varible. (here in your case you can create a customer exit variable for Document number not ready for input)
    Along with that:
    BEx User Exit allows the creation and population of variables and calculations for key figures and variables on a runtime basis.
    Step2
    After creating the variable , For populating the values use the Function module RSDPL_CUBE_DATA_READ to read the data for the cube and populate the same into the internal table.
    Step3
    For the internal table you need to sort the document number and the date so that it picks the top most record in displaying the data. and in the out you will get as you requirement is
    1 2004.006 1 10000
    1 2004.007 3 20000
    Last option but looks silly
    Develop one more Cube which is above your existing cube . and develope a start routine which takes the first record from the cube. and now you can develop the report based on the new cube ( in this new cube the data will be there for the first record)
    hope this helps
    Santosh

  • How can i transfer some fields from one table to another using a trigger

    hi,
    i have two tables;sales and accounts.i want in my accounts form to enter salesid which is then validated and if it exists in the sales table, some fields are copied to the accounts table automatically.how do i go about this.thanx

    hi,
    the code u gave me is not running.let me explain in
    detail.i have two tables;sales and accounts in my
    database (oracle 9i).each have a corresponding form
    in the developer window.these tables are linked using
    saleid.this id is entered and saved in the
    database.when the person is paying in the cash
    office,the saleid on an invoice form is entered on
    the accounts form.it is supposed to search the sales
    table and if the ids match,some records are extracted
    from the sales table to the accounts form instead of
    the accounts clerk entering the details all over
    again.these details will be used to generate a
    receipt an then the record on the accounts form is
    saved to the database.the contents of the two tables
    are:
    sales(saleid(pk),startno,endno,quantity,amount,saledat
    e)
    accounts(receiptno(pk),saleid,startno,endno,quantity,a
    mount).
    please advice and thanks very muchWhat does it mean "not running" ?
    Sure, it is running.
    Did you tested my example ?
    And it does exactly what you need.
    You didn't provided table structures and insert statements,
    that's why i showed you the method on 2 emp- tables.
    But it is exactly, what do you need.
    Change my emp_1 on your sales,
    and my emp_2 on your accounts,
    and compare the results.
    If you cannot directly copy and paste
    and say to your teacher / chief "My homework / task is ready"
    it doesn't mean, that the solution didn't provided ...

  • Auto Populate Field in One Table with Primary Key from another table.

    Greetings all,
    I have created two tables. One for Root Cause which will be the based description information of an analysis. Each Root cause can have many corrective actions.
    My Table structure is as follows:
    RCCA TABLE:
    =====================================
    Column Name     Data Type     Nullable
    RCCAID     NUMBER     No
    DESCRIPTION     VARCHAR2(4000)     Yes
    SUMMARY     VARCHAR2(4000)     Yes
    OWNER     VARCHAR2(4000)     Yes
    DATEOFINCIDENT DATE     Yes
    STATUS     VARCHAR2(4000)     Yes
    CORRECTIVE ACTION TABLE
    =====================================
    Column Name     Data Type     Nullable
    CAID     NUMBER     No
    RCCAID     NUMBER     No
    CANUMBER      NUMBER     Yes
    CACTION     VARCHAR2(4000)      Yes
    DATEDUE     DATE     Yes
    COMMENTS     VARCHAR2(4000)      Yes
    So I have a form that creates the RCCA and then I have another form that I want to feed off of the first form. My thought was that when the RCCA was created, it would open a report of the RCCA and then in another region of the page I would add corrective action form. What I am looking to do is when I press the Create Corrective Action, it will automatically populate the RCCAID in the Corrective Action Table so that it is associated directly to the RCCA. I don't want to have to have someone know what the RCCAID is from teh RCA table because they are autogenerated.
    There may be a better way to do this and since I am new to APEX and to Oracle Databases, I am just going with what my logic tells me. Any assistance or thoughts would be appreciated.
    Assuming there would be some type of trigger?
    I will have to be able to view each RCCA and CA in a report that customers will see.
    Thanks in Advance
    Wally

    Hi Debasis,
    Have a look on this
    Quick note on IDENTITY column in SAP HANA
    Regards,
    Krishna Tangudu

  • Link many fields to one table

    Hello,
    Using CR v14.
    How do I link multiple fields to the same table?
    table A:
    field 1 links to table B
    field 2 links to table B
    field 3 links to table B
    My attempt with the 'link tab' under the 'Database Expert' allows me to set the links but the report only shows records where field 1,2,3 are all the same.
    Thanks.

    Hi Eric,
    Moved your post to the Report Design forum.
    What you are doing is correct but not enough info on how the tables relate to each other. When dragging field to field in the Linking Wizard the default is a Left Outer Join so you will get multiple rows with the same numbers.
    If the linking is correct try this:
    Check on the Suppress if Duplicate and see if that's what you need. But I suspect you need Links or a Command Object to get the data you really want.
    Need more info and details about the tables you are trying to link.
    Don

  • I want to display the 3 different counts in one table

    Hi,
    I have three different counts , now I want to display the 3 counts in one table. Is it possible,
    For example :
    1. Select count(*) from table1 ;
    Ans : 10
    2. Select count(*) from table2;
    Ans : 20
    3. Select count(*) from table3;
    Ans : 30
    Now I want to display like this
    A 10
    B 20
    C 30
    Thanks

    Nihar,
    You can write a pl/sql block to achieve this
    CREATE TABLE new_table (table_name VARCHAR2 (30), COUNT     NUMBER);
    DECLARE
       CURSOR mcur
       IS
          SELECT   table_name
            FROM   user_tables
           WHERE   table_name IN ('A', 'B', 'C');
       v_sql   VARCHAR2 (100);
       v_count number;
    BEGIN
       FOR x IN mcur
       LOOP
          v_sql := 'select count(*) from ' || x.table_name;
          EXECUTE IMMEDIATE v_sql INTO   v_count;
          INSERT INTO new_table
            VALUES   (x.table_name, v_count);
       END LOOP;
       COMMIT;
    END;
    select * from new_table;Regards

  • Multiple Text Boxes Populating a Single Field

    I need to create several select lists in a form that can each populate the same field in a table, but obviously need for the select lists in the form to be mutually exclusive so that the user can only enter data into one of them.
    There is also a field on the form displayed as a radiogroup, and I would like for the user's selection on this radiogroup to dictate which one of these multiple select lists they use to enter this data.
    Before I do any of this, however, I guess my first question is, how do I create multiple text entry fields on a form for just a single field in the table?

    hi brice--
    if you're coding your form page manually, you'd simply add your extra fields to your page definition and conditionally diplay and use the values you needed. i'm guessing you're asking about wizard generated forms.
    you can associate multiple fields with a single database column on your form by simply adding the extra ones you need and conditionally displaying/processing the ones you need. your other questions sound like javascript ones to me. if it were me, i'd take a look at our javascript how-to document at...
    http://otn.oracle.com/products/database/htmldb/howtos/htmldb_javascript_howto2.html
    ...and find the specific javascript i needed from google.
    hope this helps,
    raj

Maybe you are looking for

  • Issue about Invoking a BPEL Process with the Generic Java API

    I Invoking a BPEL Process with the Generic Java API and apache axis or axis2 it turn up a error as follow: org.apache.axis2.AxisFault: ORABPEL-08021 Cannot find partner wsdl. parnterLink "BPELProcess1" is not found in process "BPELProcess1" (revision

  • BASE UOM different in R/3 and APO

    Hi Experts I am working in a scenario where we have 2 R/3 boxes connected to 1 APO. The products are common across the boxes but locations are different. We are implementing GATP with Rules based substitutions for locations across the R/3 boxes. Sinc

  • Newbe question about SG300-20 dropping port to Router

    Hello to you all Today I received my new SG 300-20 managed switch to replace an unmanaged switch with some faulty ports. I want to use it in a a combined Home / Small Office environment. It is my first purchase and use of a managed switch so am still

  • Trying to uninstall Itunes on my pc, windows vista.

    I want to install the upadates to my iphone. I can't update itunes either.  When I attempt either I get the msg: The feature you are trying to use is on a network resource that is unavailable.  Then it says to enter an alt path to a folder containing

  • BEX analyzer -Maximum number of rows (65535) exceeded. Result is incomplete

    Hello Experts, I am trying to Run a report on BEx Analyzer.There are around 200,000 records to be displayed in the result. I am getting the below error. Maximum number of rows (65535) exceeded. Result is incomplete. Message no. BRAIN675 We are on SAP