Transposing column 1 data as columns and column 2 data as records

Hi Sirs,
I have a table having data in the form
Present data format          
Interview_no     Question     Answer
1     Q1     A1.1
1     Q2     A1.2
1     Q3     A1.3
1     Q4     A1.4
1     Q5     A1.5
1     Q6     A1.6
1     Q7     A1.7
2     Q1     A2.1
2     Q2     A2.2
2     Q3     A2.3
2     Q4     A2.4
2     Q5     A2.5
2     Q6     A2.6
2     Q7     A2.7
3     Q1     A3.1
3     Q2     A3.2
3     Q3     A3.3
3     Q4     A3.4
3     Q5     A3.5
3     Q6     A3.6
3     Q7     A3.7
4     Q1     A4.1
4     Q2     A4.2
4     Q3     A4.3
4     Q4     A4.4
4     Q5     A4.5
4     Q6     A4.6
4     Q7     A4.7
what I need is to change it into
Required format                                   
Interview_no     Q1     Q2     Q3     Q4     Q5     Q6     Q7
1     A1.1     A1.2     A1.3     A1.4     A1.5     A1.6     A1.7
2     A2.1     A2.2     A2.3     A2.4     A2.5     A2.6     A2.7
3     A3.1     A3.2     A3.3     A3.4     A3.5     A3.6     A3.7
4     A4.1     A4.2     A4.3     A4.4     A4.5     A4.6     A4.7
I am sorry to use that much of space but I think this was the best way to ask the problem. Can we do this using SQL only or we need to go for Pl/Sql I have tried writing a procedure but can't get what eactly I want. I also serched on the net there are a few articles on transposing but they didn't help a lot.
Please help me with the code.
Thanks & Regards

SQL> ed
Wrote file afiedt.buf
  1  with t as (select 1 as interview_no, 'Q1' as question, 'A1.1' as answer from dual union all
  2  select 1, 'Q2', 'A1.2' from dual union all
  3  select 1, 'Q3', 'A1.3' from dual union all
  4  select 1, 'Q4', 'A1.4' from dual union all
  5  select 1, 'Q5', 'A1.5' from dual union all
  6  select 1, 'Q6', 'A1.6' from dual union all
  7  select 1, 'Q7', 'A1.7' from dual union all
  8  select 2, 'Q1', 'A2.1' from dual union all
  9  select 2, 'Q2', 'A2.2' from dual union all
10  select 2, 'Q3', 'A2.3' from dual union all
11  select 2, 'Q4', 'A2.4' from dual union all
12  select 2, 'Q5', 'A2.5' from dual union all
13  select 2, 'Q6', 'A2.6' from dual union all
14  select 2, 'Q7', 'A2.7' from dual union all
15  select 3, 'Q1', 'A3.1' from dual union all
16  select 3, 'Q2', 'A3.2' from dual union all
17  select 3, 'Q3', 'A3.3' from dual union all
18  select 3, 'Q4', 'A3.4' from dual union all
19  select 3, 'Q5', 'A3.5' from dual union all
20  select 3, 'Q6', 'A3.6' from dual union all
21  select 3, 'Q7', 'A3.7' from dual union all
22  select 4, 'Q1', 'A4.1' from dual union all
23  select 4, 'Q2', 'A4.2' from dual union all
24  select 4, 'Q3', 'A4.3' from dual union all
25  select 4, 'Q4', 'A4.4' from dual union all
26  select 4, 'Q5', 'A4.5' from dual union all
27  select 4, 'Q6', 'A4.6' from dual union all
28  select 4, 'Q7', 'A4.7' from dual)
29  -- END OF TEST DATA
30  select interview_no
31        ,max(decode(question,'Q1',answer)) as Q1
32        ,max(decode(question,'Q2',answer)) as Q2
33        ,max(decode(question,'Q3',answer)) as Q3
34        ,max(decode(question,'Q4',answer)) as Q4
35        ,max(decode(question,'Q5',answer)) as Q5
36        ,max(decode(question,'Q6',answer)) as Q6
37        ,max(decode(question,'Q7',answer)) as Q7
38  from t
39  group by interview_no
40* order by interview_no
SQL> /
INTERVIEW_NO Q1   Q2   Q3   Q4   Q5   Q6   Q7
           1 A1.1 A1.2 A1.3 A1.4 A1.5 A1.6 A1.7
           2 A2.1 A2.2 A2.3 A2.4 A2.5 A2.6 A2.7
           3 A3.1 A3.2 A3.3 A3.4 A3.5 A3.6 A3.7
           4 A4.1 A4.2 A4.3 A4.4 A4.5 A4.6 A4.7
SQL>

Similar Messages

  • Exporting data in rows and columns and loading in RDBMS

    <p>I have a scenario wherein i want to export data from HyperionEssbase in <b>rows and coulmns</b> and <b>load it into</b><b>RDBMS</b>. I can load data into RDBMS using informatica if theflat file exported is in form of rows and columns.But when i exportthe file using Hyperion Essbase 9 i get it in from of alldimensions and then the fact value which is not how i want. I wantdata in relational from in flat file itself(row,column).</p><p>Looking forard to your suggestions..Thanks in advance..</p>

    <p>Thanks <b>willjordan</b> and <b>twakim</b> for yoursuggestions..</p><p> </p><p>I tried both the techniques and both worked...</p><p>With reference to the technique suggested by <b>twakim</b> , I was able to use that in Hyperion Essbase 9..But in myreal scenario the cube is in Hyperion Essbase 6.5.4.2..Can i usethis Custom defined functions in Hyperion Essbase 6.5.4.2..and ifso how as there is no concept of Analytical server there???</p><p> </p><p>Please help me in this issue???<br></p>

  • Dates against rows and columns in pivot require two date dimensions???

    Hi,
    I have an Excel pivot table connected to a SSAS tabular cube.Now For this Report i want the row label area of pivot to contain Shipping Month and column label area contains the Order Months.Do i need two date dimensions for this purpose?? What is the way
    to do such kinds of Reports where the row as well as columns contain date dimension???
    Thanks.

    Hi Nimo0102,
    Based on your description, you want Shipping Month to be shown on row label, and Order Months to be shown on the column label, right? When connecting to a data base on an Excel pivot table, if we want to the dimension appear on the row or column label, we
    can drag the dimension to ROWS or COLUMNS. So in your scenario, if you have Shipping Month Order Months on your cube, you can drag it to ROWS or COLUMNS directly. Otherwise, I am afraid you need to create them on the cube.
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Unable to set columns under Layout Margins and Columns

    On certain pages in my 40 page document, I am unable to set the number of columns by using Layout>Margins and Columns. The columns option is dimmed out. I have tried to set them on a blank page and pages where columns were previously set (I can see the guides). I am using a single Master for page numbering and it is applied to every page in the document. There are pages where I can set the columns. I've done some page comparison and can't find the setting that might control this. Using InDesign CS6 on Windows. Thank you.

    Why are you not using multiple column text frames instead of 2 text frames with columns on the master page? This would give more flexiblity.

  • How To Use OATS To Pull Data From DB And Insert Data Back To DB

    Hi All,
    My requirement is little different.
    I'll explain the scenario,
    I am working on OTM application, as far as I have read OAST supports OTM and already test scripts are ready.
    My situation is as follows bellow,
    I need to pull data of a field for 18,000 shipments.
    I have an excel sheet in the format as bellow
    Shipment_Number
    Stop_Number
    Planed_Arrival_Date
    Planed_Departure_Date
    1
    1
    1
    2
    1
    3
    2
    1
    2
    2
    I was able to write script in OATS so that it logins to OTM and searches for the specified shipment number and capture the Planed_Arrival_Date and Planed_Departure_Date for the specific stop.
    But the problem is I am not able to save the date back to the excel.
    Solution Expecting:
    Some way to save the captured data back to excel.
    Some way to save the captured data back to a column in a table. if this is possible then some way to make OATS reade the shipment number from a column in database.
    Thanks,
    Vishwamber Shetty

    Hi Vishwamber,
    Try using Datatable in OATS. Using datatable you can read and write to Excel.
    Regards,
    Deepu Muraleedharan

  • Copy data customer PO and PO date field from quotation to sales order

    Hi Friends,
    Can you please let me know what copy control settings I need to maintain in order to copy customer PO# and PO date field data in quotation to sales order.
    All the data is getting copied from quotation to sales order when I create sales order with reference to quotation but the customer PO no. and PO date is not getting copied.
    Can anyone please help.
    Regards,
    Wasim.

    HI
    Not sure if this is possible via Customization or not but you can try the user-exits or Routines for the Sales Order program for this
    You need to change the include FV45C102 (assuming you have copied standard order and the copy controls). ABAP team should be able to make changes to this routine and achieve your requirement.
    In VTAA, after choosing the Source and Target order type and choosing the right Quatation item, check the routine for 'Bus.data/item compl.' and it will be what has been mentioned above.
    Please check &Revert
    Thanks&Regards
    Raghu.k

  • Posting date in AFRU and 2lis_04_p_arbpl data source is not matching

    Hi Experts,
    We are facing an issue with 2LIS_04_P_ARBPL data source, posting date in AFRU table and in data source is not matching.
    For example: we booked an activity confirmation of value 100 on 01.01.2015 posting date, Counter 1, Operation 10
    For the same operation another counter is confirmed on 01.02.2015 posting date.
    So, in AFRU table:
    Prod Order     Operation     Confirmation Number     Counter     PostingDate     Activity
    1001               10               8001                             1              01.01.2015       100
    1001               10               8001                             2              01.02.2015       0
    In 2lis_04_p_arbpl data source, counter field is missing due to which only 1 record is coming which is:
    Prod Order     Operation     Confirmation Number     Counter     PostingDate     Activity
    1001               10               8001                             1              01.02.2015       100
    In data source, activity of value 100 is coming on 01.02.2015 date instead in AFRU table it is booked on 01.01.2015 posting date by which we are unable to match the value in query which is based on posting date.
    Please help on this.
    Thanks,
    Sameer

    Hi Sameer,
    Please check on which date the production order has status as "completed".
    It could be on 01.02.2015.
    Thanks,
    Vimal

  • How to Convert internal table data into xml and xml data into internal tab

    Hi Guys,
          I have a requirement  that  i have to convert the internal table data into xml format and viceversa . for my requirement  i came to know that i have to use Transformations concept.  i done the converting the data from internal table into xml data by using standard Tranformations. My Question is 
    1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
    2) Is it possible using the standard Transformation  or I have to go for XSLT approach
    Please help me out from this guys,
    Thanks and Regards
    Koti

    Hi Koti,
    This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
    Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31

  • HR Master Data IDoc HRMDa and validity date

    Hi
    I have a record in infotype 8:
    - from 01.05.2011 to 31.12.9999.
    When I use PA30, I copy this record and change the dates from 05.05.2011 to 31.12.9999. Previous record of course changes the validity dates from 01.05.2005 to 04.05.2011, and second record is created with dates from 05.05.2011 to 31.12.9999.
    The problem is with incoming IDoc. When I have the same situation as described below, instead of PA30 I use incoming IDoc. Unfortunately previous record does not get changed and I have two records both valid to 31.12.9999. I use "U" in operation in IDoc.
    What is wrong?

    Hi,
    This is due to how ALE works, please check note 134085. So basically
    system will first delete the infotype records between E1PITYP-BEGDA and
    E1PITYP-ENDDA, and then it will create the records with the information
    in segment E1Pxxxx (xxxx corresponds to the infotype number). If you
    just send information between dates 05.05.2011 to 31.12.9999, no
    record is deleted in target (so original record remains there), and just
    the new record in the IDOC (the one from 05.05.2010 to 31.12.9999)
    will be updated there. Therefore  you will finally get those two
    records in target system with same end dates.
    If you create the IDOCs using standard tools, then this should be
    done correclty.
    Regards,
    Ana

  • How to report on dates between From and To dates

    Hi forum,
    I have a requirement to report on Long Term Absences from work.  The user wants to enter a calendar month in a selection variable, and see who is away from work in that month.
    I have the start and end dates of absences, but these are long term absences which span across months.  The problem is, if I base the Calendar Month variable on the start date or the end date of the absence, people get missed off the report.
    For example, if we have someone on maternity leave for a year, the user wants to be able to enter any month within that year, and see that the person is on maternity leave.  So I cannot use the start date or end date of the absence as it is.
    How do I get the report to run such that when a user enters a month, it will show everyone who is absent on any dates within that month?  I assume I need some kind of customer exit variable for this, but is there a standard SAP delivered variable which will work out all possible dates within the start and end date?  Or do I need to write some code myself?
    I couldn't see anything in the forum already which would help me on this, but if there is an existing thread, please also let me know.
    Many thanks
    Mischa

    Hi Mischa.
    I think you can achieve what you want like this
    Add the Start Month and End Month (let them be IO's that reference 0calmonth) to your cube and  populate them in the load using a formula, like Aron suggested.
    Create a query with a  restricted key figure.  I suppose you are looking at some kind of count  to know how many people where absent in a given month, or something like that. Thus, add your KF to the structure and add the Start Month and End Month to the selection.
    Restrict the Start Month using a variable, ZMONTH (this is what the user will enter at runtime), as follows:
    Start Month <= ZMONTH.
    Now restrict the End Month using a variable, XMONTH (this will have to be an exit variable filled in CMOD by reading ZMONTH) as follows:
    End Month >= XMONTH.
    Thus, your restricted key figure will only return values if the entered month is part of the absence interval. The abap you need for CMOD should be simple as all you are doing is reading a variable and passing it to another. From the top of my head, it should look something like this:
    data:
    l_s_range type rsr_s_rangesid,
    loc_var_range like rrrangeexit.
    case i_vnam.
    the case statement will likely already be there, as well as the above definitions, so look for the case and insert the below
    when 'XMONTH'.
    if i_step = 2.
    clear l_s_range.
    loop at i_t_var_range into loc_var_range
    where vnam = 'ZMONTH'.
    l_s_range-low = loc_var_range-low.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'EQ'.
    append l_s_range to e_t_range.
    endloop.
    endif.
    endcase.
    this will likely already be there, so you won't need to put it there again.
    Good luck!
    Jacob
    Edited by: Jacob Jansen on Jan 11, 2010 9:18 PM
    Edited by: Jacob Jansen on Jan 11, 2010 9:30 PM

  • Do not get any data from 0CA_IS_TS_1 and 0CA_IS_TS_2 data source

    Hi all,
    We are trying to populate cubes(0CATS_C01) and (0CATS_C02) for which data sources are 0CA_IS_TS_1 and 0CA_IS_TS_2 respectively. We activated business content for these data sources. When we run these data sources in RSA3 we do not get any data even though we have data in the repective tables. We applied SAP Note :1586467, which says (Note 1586467 - Extractor 0CA_TS_IS_1 returns no data), Can you please help me out in knowing if we are missing some thing?
    Thank you,
    Bob.

    Hi,
    To use this DataSource you must have implemented Support Package SAPKH46C32, or have made the relevant corrections in SAP Note 509592.
    Pl check you have required data as mentioned below
    When transferring time sheet data to the Business Information Warehouse (BW), you must note the connection between the following data sources:
    ·        CA_TS_IS_1 (Time Sheet Data (Approved))
    Documents are written in the SAP R/3 system for Time Sheets with status 30 (approved). The documents log the changes that have been made to data records.
    Therefore, the SAP R/3 system can perform a delta update for this data source. The system only transfers newly approved data records and changes that have been made to existing data records. At the same time, the SAP R/3 system notes the date of the last delta transfer.
    ·        CA_TS_IS_2 (Time Sheet Data (Released for approval))
    The SAP R/3 system does not write documents for Time Sheet data with status 20 (released for approval). This means that changes made to these data records are not logged.
    Therefore, the SAP R/3 system always performs a complete transfer of data records that have been released for approval. The number of data records that need to be transferred usually remains constant because in the period between two transfers not only new data records are added but other data records are also approved. Therefore, system performance is not restricted.
    Thanks and regards

  • What is the data source name and the data target name for the table COSP

    Hi,
    Actaully i am new to fico/bw,and i have to create a report based on the actual and budget value and difference in the variance.
    in R/3 side the table they are using is COSP,so please let me know what is the data source name and the cube or ods name in BW side.wht are the fields in which i can get the BUDGET value in the report.
    here we are using all the business content extractors and BI content cubes and odss.
    please reply immediately as its very jurgent isssue.
    Thanks,
    ashok

    answered

  • CSS sheet covers up date drop down, and other Date field issues

    Portland needs a little help once again.
    My CSS stylesheet object acts like it has a higher "zIndex" then the date dropdown on an inputField.  This causes me to only see half the calendar or none of it.  Anyone else seen this and how did you get around it.
    Also, When I test my BSP page the date drop downs, tables, etc all look great.  However when the BSP page is rendered on an iView in EP6.0 they look terrible.  Colors change, etc.  What is happening here and how do I get around it.
    Much Thanks in Advance,
    Anthony

    Please make these corrections in to your system that solves your problem.
    1) Call transaction se80                                               
    2) Click on "MIME Repository"                                          
    3) Goto /SAP/PUBLIC/BC/UR/Design2002/js                                
    4) Open each of these files:                                           
           sapUrMapi_ie5.js                                                 
           sapUrMapi_ie6.js                                                 
           sapUrMapi_nn6.js                                                 
           sapUrMapi_nn7.js                                                 
        and replace 'ur_pop_' with 'ur_'                                    
        and replace 'class=\"urCalArrPrev\"' with                           
        'class=\"urPagHBtnPrevItem\" style=\"background-repeat:no-repeat;   
    background-position:left\"'                                            
        and replace 'class=\"urCalArrNext\"' with                           
        'class=\"urPagHBtnNxtItem\" style=\"background-repeat:no-repeat;    
    background-position:right\"'                                           
        and replace 'class=\"urCalArrNextDsbl\"' with                       
        'class=\"urPagHBtnNxtItemDsbl\" style=\"background-repeat:no-repeat;
    background-position:right\"'

  • Refresh buffer when rfc gets data from crm and the data was updated from R3

    hi all
    I have a program in r3 for maintenance of partners, so the user can create or update a CRM partner from the R3 system. if you are updating a partner, the program gets the data from CRM via RFC and saves the changes via zBDoc. if the user modify a partner and then try to check if the info were updated, he needs to leave the transaccion and run it again in order to the RFC gets the data updated. how I can avoid to leave the transaccion? i tried with a buffer refresh and commit but it doesn't works.... any idea?
    tnks

    Hi Alan,
    THANK YOU for that hint. That brought me a giant step further, seriously! Many thanks! Now my report is running and hourly creating an instance, reeally nice!
    But of course, the next problem is arising rapidly: Now that I got my report creating instances, the funny thing happening is the following: I created the WebI report with the WebI-Rich Client and then saved it to the server. In InfoView I scheduled the instance creation and the strange thing is now: The values differ. In the original report the values for some percentage ratios (e.g. 50%) show up as they should with four decimals: 0,5000 (German way of displaying numbers with decimals). BUT: In the instances of the same report, exactly these numbers would appear as 0,0000. So the numbers would just not be displayed! But all other numbers (all numbers not having decimals) would show up as they are supposed to even in the instances of the report.
    This is kind of strange to me. Does anybody have a clue what the problem might be?
    Many thanks again! And I hope I am not bothering you guys with these "newbie" questions.
    Thanks and best regards,
    Kai

  • Prompt  with  default  date   (  currentdate-1  and current date-8)

    Dear all,
      I am creating an @prompt varaiable for Date .
    @Prompt('message','type',lov,Mono, free,persistent,default_values)
    Requirement is in Place of "Default Values"   i need show  currentdate -1 and  currentdate-8 .
    Thanks
    suresh.p

    Hi Suresh,
    I have got more idea to do this.
    1 .Build another object of the same field in unv = u201CDate Rangeu201D
    code:
        case when (Date between trunc(sysdate u2013 1) and trunc(sysdate)) then u2018Yesterdayu2019
                 when (Date between trunc(sysdate u2013 8) and trunc(sysdate+1)) then u2018Last 8 Daysu2019
       end
    2. Now Add Yesterday in the defalut for currentdate-1 promp or u2018Last 8 Daysu2019 for currentdate-8 Prompt.
    = @Prompt(u2019Date Pickeru2019,'Au2019,DateX,mono,constrained,persistent,{u2019Yesterdayu2019})
       Create this prompt in the "Date Range" objects. or create a condition, What ever way you want it.
    Please try this and see if this can work without any parsing error.
    Edited by: srrachna on Mar 17, 2011 12:06 PM

  • How can I change the location where iTunes saves iOS 5.1, new data, synchronized apps and other data?

    My hard drive C is full. I changed the location of the mediathek to an external hard drive F and moved all media data there. Also, I synchronized my iPad with this new set-up. So far, everything worked out well.
    Now, why is iTunes stll saving data, like the much needed iOS 5.1, to C? This actually makes it impossible for me to finally update my iPad, because my C drive is simply full!
    Also, iTunes does not synchronize my iPad apps or my photos. When I try to synchronize them manually, iTunes starts to save data to my C drive. How can I change that to my external drive F?
    In a nutshell, how can I move iTunes once and for all to my external hard drive F (or at least, to a different hard drive on my computer)? There is simply no space on my C drive for it at all.
    Thankyou so much for an answer, I am literally going nuts right now!

    I found the app that I'm looking for it's called sensor kinetics pro and the link is
    https://itunes.apple.com/us/app/sensor-kinetics-pro/id623633248
    Message was edited by: lightninginajar

Maybe you are looking for

  • Macbook PRO 2009 running extremely slow all of a sudden

    Hello, I have been encountering recent problems regarding my macbook pro 15" from 2009. All of a sudden it became extremely slow and spinning beach ball every time I click something. It used to be very fast it's as if something happened over night. I

  • How do i set a homepage in safari on ipad

    I clicked on the left arrow at the top as suggested but all I got was instructions for firefox. I am using explorer

  • Report viewer web part, show different report everyday (rotate .rdl files)

    We have a report viewer web part on sharepoint site (intranet), which is working fine and showing the report (.rdl file). We want to show different report everyday by looping through a list of 4 or 5 important reports  (from sharepoint document libra

  • Radio Buttons + Required Input/Output Fields in Dialog Programming

    Hi All, Please find the below issue. I have 2 Radio buttons RB1 and RB2 defined in group RG. And by default RB1 is selected. I also have 3 Input.Output Fields. F1 , F2  & F3. Now before displaying the Screen for the end user, I need to display as fol

  • PREREQISITE SETTINGS IN R/3,SLD,XI

    hi could you tell me who does actually sets the prerequisite settings in real time for the scenarios involving IDOC, RFC......which needs some settings as everyone will not hv access to some components,; Please elucidate this as I need to face interv