How to 'pivot' a table without aggregating the data?

Hi!
Suppose I have a simple query which returns the 1st (yellow) table in the attached picture.
I wish to convert this table to the 2nd table (green). This is sort of a pivoted table, but all the individual rows are shown separately, and not aggregated
How can this be done?
The simple query could be as follows:
CREATE TABLE #Table1
(Type varchar (10),
DocNum Int,Qty Int)
Insert into #Table1 Values
('SOrder', '1125','100'),
('POrder','4615','50'),
('POrder','4616','50'),
('GRPO','2001','25'),
('GRPO','2002','25'),
('GRPO','2003','25')
SELECT * FROM #Table1
Note: In the "transposed" table, the rows can be in any order
Thanks
Leon Lai

Hi Visakh,
Thanks a lot for your reply.
It works fine for me, and your query gave the foll. results which are exactly what I wanted:
Sorder_Type
SOrder_DocNum
Porder_Type
POrder_DocNum
GRPO_Type
GRPO_DocNum
SOrder
1125
POrder
4615
GRPO
2001
NULL
NULL
POrder
4616
GRPO
2002
NULL
NULL
NULL
NULL
GRPO
2003
I cant understand reason behind requirement like this
It is rather difficult to explain my rationale in this forum.
In brief, I am developing a kind of relationship map for all documents in a chain of transactions.
I would need to trace all base documents and all target documents in the chain, but the relationships
can be extremely complex in real life. So, I chose to ignore all  the exact joins, and to simply list the relevant documents in any
order.
It is quite remarkable that you have correctly answered my question, even though you could not understand my rationale. 
Best Regards
Leon 

Similar Messages

  • How can i access a mysql table without putting the data in a datagrid

    I developed my air app with a datagrid which uses a php service to display all data from a table of strings in MySql.
    I now do not need the datagrid, how can i get the data from my database without putting it into a dataGrid? Do i need an array? how do i do this? anyone got any example code?

    Balakrishnan V wrote:
    var resultArrayCollection:ArrayCollection=new ArrayCollection()
    protected function resultHandler(event:ResultEvent)
         result=event.result as ArrayCollection
    You can use the result array collection now inside your program for any further changes / manipulations.
    Hope this helps; If you have further doubts, do ask...
    Balakrishnan V
    Hi, yeah this helps,
    however, how would i generate a result handler for a service that has not been called yet? Sorry my knowledge of services is very limited.
    This is a php service, get_all service that returns all the rows from a mysql table.
    I can see the service box with the service i want to use:
    but how do i pass that to a result handler?

  • How to read a table and transfer the data into an internal table?

    Hello,
    I try to read all the data from a table (all attribute values from a node) and to write these data into an internal table. Any idea how to do this?
    Thanks for any help.

    Hi,
    Check this code.
    Here i creates context one node i.e  flights and attributes are from SFLIGHT table.
    DATA: lo_nd_flights TYPE REF TO if_wd_context_node,
            lo_el_flights TYPE REF TO if_wd_context_element,
            ls_flights TYPE if_main=>element_flights,
            it_flights type if_main=>elements_flights.
    navigate from <CONTEXT> to <FLIGHTS> via lead selection
      lo_nd_flights = wd_context->get_child_node( 'FLIGHTS' ).
    CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
      IMPORTING
        TABLE  = it_flights.
    now the table data will be in internal table it_flights.

  • Updating tables without contaminating the data

    Hi,
    We have two tables called EMP and DEPT
    SQL >DESC EMP;
    Name Null? Type
    EMP_ID NOT NULL NUMBER(12)
    EMPNAME NOT NULL VARCHAR2(25)
    DEPT_NO NUMBER(10)
    SQL >DESC DEPT;
    Name Null? Type
    DEPT_NO NOT NULL NUMBER(10)
    DEPTNAME NOT NULL VARCHAR2(25)
    We don't have any foreign key constraints in between these two tables.
    We have already data in both these tables..
    For Ex in DEPT table.
    1 ACCOUNTS
    2 SALES
    3 FABRICATION
    We would like to change this table to
    2 ACCOUNTS
    3 SALES
    1 FABRICATION
    These are sample records . We have huge amount of data.
    How to solve this problem with out contaminating the data in the EMP Table..
    Thanks in Advance..
    -Sateesh

    Kevin,
    Right you are. Must be too early for me.
    How about udpate to some other number(s) first, then the actual number
    Using his example data
    FIRST
    update dept set dept_no = 10 where dept_no = 1 ;
    update dept set dept_no = 20 where dept_no = 2;
    update dept set dept_no = 30 where dept_no = 3;
    THEN
    update dept set dept_no = 2 where dept_no = 10;
    update dept set dept_no = 3 where dept_no = 20;
    update dept set dept_no = 1 where dept_no = 30;

  • How to display a table without selecting the first row as default ?

    Hello All,
      Can someone advise on how I am able to display a table but with no row selected on initial display ? Currently, the table is being displayed with the first entry selected by default (The orange box is selected). Thank you very much.
    from
    Kwok Wei

    Javadoc for IWDNode says:
    public void clearSelection()
        Clears the Node's multiple selection; does not change the lead selection.
    public void setLeadSelection(int index)
        Sets the lead selection to the given index. It may be called with NO_SELECTION to reset (clear) the lead selection.
        Parameters:
            index - the index of the element
        Throws:
            ContextException - if caller tries to reset the selection, but selection is mandatory
            IndexOutOfBoundsException - if the given index is not within the element list
        See Also:
            getLeadSelection()
    Armin

  • How to reordering a table without coloring the entire column ?

    Hi,
    When I click on a column header to re-order the table, the entire column is show in a differente color. Is there any way to avoid this behave ?
    Thanks,
    M�rcio

    Javadoc for IWDNode says:
    public void clearSelection()
        Clears the Node's multiple selection; does not change the lead selection.
    public void setLeadSelection(int index)
        Sets the lead selection to the given index. It may be called with NO_SELECTION to reset (clear) the lead selection.
        Parameters:
            index - the index of the element
        Throws:
            ContextException - if caller tries to reset the selection, but selection is mandatory
            IndexOutOfBoundsException - if the given index is not within the element list
        See Also:
            getLeadSelection()
    Armin

  • How to find certain words based on table without overwriting the old one

    Hello,
     I have a list of words available in one particular table, based on those records i need to match it up with one specific column on another table. Based on that match i need to update the same. below is answer for this question;
    Design a new query. Select your data table and your words table. No join line between them.
    Drag datatable.* to the design grid, and the field to check. In the criteria for that field write:
    Like '*' & [wordstable]![wordsfield] & "*"
    (of course you change this to your object names)
    But now my another question is that how i can do update without replacing the existing one. Like for example " Peter is engineering degree".
    In this example if i have words like ring and degree on my reference table, then as per the solution it will update the degree first then later if its find ring on the text then it will overwrite the degree on the particular column. How i can prevent
    this?
    VinWin06

    But now my another question is that how i can do update without replacing the existing one. Like for example " Peter is engineering degree".
    I think what you are saying is that you want to avoid specious substring matches such as finding 'engineering' when searching for 'ring'.  Right?  If so use the following function rather than the LIKE operator to identify the 'word' rather than merely
    a substring:
    Public Function FindWord(varFindIn As Variant, varWord As Variant) As Boolean
       Const PUNCLIST = """' .,?!:;(){}[]/"
       Dim intPos As Integer
       FindWord = False
       If Not IsNull(varFindIn) And Not IsNull(varWord) Then
           intPos = InStr(varFindIn, varWord)
           ' loop until no instances of sought substring found
           Do While intPos > 0
               ' is it at start of string
               If intPos = 1 Then
                   ' is it whole string?
                   If Len(varFindIn) = Len(varWord) Then
                       FindWord = True
                       Exit Function
                   ' is it followed by a space or punctuation mark?
                   ElseIf InStr(PUNCLIST, Mid(varFindIn, intPos + Len(varWord), 1)) > 0 Then
                       FindWord = True
                       Exit Function
                   End If
               Else
                   ' is it precedeed by a space or punctuation mark?
                   If InStr(PUNCLIST, Mid(varFindIn, intPos - 1, 1)) > 0 Then
                       ' is it at end of string or followed by a space or punctuation mark?
                       If InStr(PUNCLIST, Mid(varFindIn, intPos + Len(varWord), 1)) > 0 Then
                           FindWord = True
                           Exit Function
                       End If
                   End If
               End If
               ' remove characters up to end of first instance
               ' of sought substring before looping
               varFindIn = Mid(varFindIn, intPos + 1)
               intPos = InStr(varFindIn, varWord)
           Loop
       End If
    End Function
    You can supplement this with the following functions to find any or all of multiple words in the same string expression:
    Public Function FindAnyWord(varFindIn, ParamArray varWordList() As Variant) As Boolean
        Dim var As Variant
        For Each var In varWordList
            If FindWord(varFindIn, var) Then
                FindAnyWord = True
                Exit Function
            End If
        Next var
    End Function
    Public Function FindAllWords(varFindIn, ParamArray varWordList() As Variant) As Boolean
        Dim var As Variant
        For Each var In varWordList
            If Not FindWord(varFindIn, var) Then
                FindAllWords = False
                Exit Function
            Else
                FindAllWords = True
            End If
        Next var
    End Function
    You can edit the PUNCLIST constant in the first function to allow for any other terminating or leading punctuation characters which may exist, in non-English text for instance.
    Ken Sheridan, Stafford, England

  • Hi. How can I delete the table without deleting the content? My pages is 5.2.2.

    Hi. How can I delete the table without deleting the content? My pages version is 5.2.2. Thank you for your help.

    There is no convert Table to text capability in Pages v5.2.2, as there was in Pages ’09 v4.3.
    You can keep the table while making the table grid vanish, leaving the existing tabular text structure. Select the table, and under the Format panel > Table tab, the following settings will produce this output. If selected, you can refine its document placement in the Arrange tab.

  • How to include in table of contents the list of figures and list of tables?

    How to include in table of content the "Table of contents", "List of figures" and "List of tables"? All are generated with function Table of contents, but they will not appear in generated table of contents even if they have proper style of headings - Heading 1, as other chapter.
    I get this in generated Table of contentes of my dissertaion thesis:
    Table of contents
    Preface
    Table of contents <- missing
    List of tables <- missing
    List of figures <- missing
    Introduction
    Main
    Conclusion
    Is it ok, that generated lists are not included in table of contents?

    You've just confused me.
    My understanding of how this is set up is that either:
    This is a book, and there is a master TOC that includes all book documents and a document-specific TOC in each component file, or
    This is a single file and there is one master TOC that includes all sections and a section-specific TOC that includes only the individual section.
    In the first case, I think you would want two TOC styles set up, one that includes the chapter heads (if I understood how you said this worked) for the for the master, and you would include all docs in the book when you generate it, and a second style for the individual chapters, with the subheadings you want to include.
    In the second case, it would be similar, but instead of only one style to cover the section TOCS, I think you would need to create a unique set of pargraph styles for the headings in each section (they can all be the same format, based one section, just with unique names), and then make a TOC style for each section that includes only the styles from that section.
    OK,  wait a sec. I just reread what you said: "Another thing: when the numbers are "linked" and updating well, they  display indide a little box. Not a text box, but a kind of little frame  around the numbers. That frame makes it imposible to delete just one  number: when the TOC says that Section 6.1 is in page 135, for example,  you cannot delete just the 5, it deletes, not just the 3 numbers, but  also the doted tab."
    I think these are NOT normal TOCs created by using Layout > TOC (but you could replace them with ones that are, if you set up your styles properly and the text you want to include is appearing on the pages). Those little boxes you mention sound like cross-references, which should update automatically without any intervention at all. Unfortunately, cross-refs can be flakey, especially if they point to another document. I'd open the cross-refs panel and see if you need to recreate a bunch of links.

  • Urgent:How to modify a script without changing the print programme

    Hi all,
    Can any body pls tell me <b>How to modify a script without changing the print programme</b>
    Give m esome real time examples.
    Good points willbe rewarded
    Thanks

    Hi
    You can write a external Subroutine to fetch the extra data into the script program
    see the following sample code
    How to call a subroutine form SAPscripts
    The Form :
    /:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
    /:USING &EKKO-EBELN&
    /:CHANGING &CDECENT&
    /:ENDPERFORM
    The report :
    REPORT zkrpmm_perform_z1medruck .
    DATA : BEGIN OF it_input_table OCCURS 10.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_input_table.
    déclaration de la table output_table contenant les
    variables exportées
    DATA : BEGIN OF it_output_table OCCURS 0.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_output_table.
    DATA : w_ebeln LIKE ekko-ebeln,
    w_vbeln LIKE vbak-vbeln,
    w_zcdffa LIKE vbak-zcdffa.
    FORM CDE_CENT
    FORM cde_cent TABLES input output.
    it_input_table[] = input[].
    it_output_table[] = output[].
    READ TABLE it_input_table INDEX 1.
    MOVE it_input_table-value TO w_ebeln.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = w_ebeln
    IMPORTING
    output = w_ebeln.
    SELECT SINGLE zcdffa FROM ekko
    INTO w_zcdffa
    WHERE ebeln = w_ebeln.
    it_output_table-name = 'CDECENT'.
    MOVE w_zcdffa TO it_output_table-value.
    MODIFY it_output_table INDEX 1.
    output[] = it_output_table[].
    ENDFORM.
    COPING SCRIPT
    There are some Standard Sap Scripts in SAP. We cant directly execute them in scripts we have to use some T-codes and by giving some input to the required fields we can see the output printform.
    I will show one example. There are some Standard Sap Scripts such as MEDRUCK which is a standard Sap Script for Purchase Order and RVINVOICE01 for billing and so on...
    To see oupt of MEDRUCK go to T-code ME9F give purchase order number and execute select one number and click on dislplay messages button on application tool bar you can find the print form of MEDRUCK.
    You cannot change the Standard Sap Scripts but you can use Standard Sap Scripts and Copy them to userdefined Script and can make changes to them and replace standard Sap Script with usedefind script.
    Ex: Go to SE71,
    on menu bar u find Utilities->copy from Client. click on it u ll find new screen showing
    Form name:
    Source Clinet:
    Target Form:
    give Form name as usedefined form name EX: ZFORM1
    Source client as 000 and
    Target form as MEDRUCK.
    execute.
    Now, the standard from MEDRUCK is copyied to your form ZFORM1.
    NOW, go to SE71 and give form name as ZFORM1 and do some changes to the form such as adding logo any thing. save and Activate.
    Now, you have done changes to the Form ZFORM1 and u have to replace your form with standard SAP Script.
    Go to NACE Transaction.
    on Applications select EF for purchase order and click Output types button on application tool bar.
    now select NEU as output types dobule click on Processing Routines.
    now click on Change option on application tool bar and on right side u find MEDRUCK in form place replace MEDRUCK with ZFORM1 and SAVE.
    go back twice and now go to T-code ME9F give the purchase order number and execute and select one option and click on display messges button .
    you will find the changes that you have done in ZFORM1. so we cant chage the standard Sap Scripts by copying the Standard Sap Scripts we can chage and replace with our forms
    Refer
    https://forums.sdn.sap.com/click.jspa?searchID=4089895&messageID=3239299
    Regards
    Message was edited by:
            Kiran Sure(skk)

  • Note:304522.1 How to Move Queue Tables without using export import

    Trying to use the pkg available in Metalink "Note:304522.1 How to Move Queue Tables without using export import"
    Using the 10.1.0.x and upwards Package, I'm getting the following error on a single consumer queue table with an xmltype payload:
    SQL> exec move_aqt.move('XFORM_TEST_INT','INTERFACE_XML_QUEUE','SMALLBLOCK');
    BEGIN move_aqt.move('XFORM_TEST_INT','INTERFACE_XML_QUEUE','SMALLBLOCK'); END;
    ERROR at line 1:
    ORA-20000: ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SYS.MOVE_AQT", line 652
    ORA-06512: at line 1
    We've tried in multiple environments, always with the same results.
    Trace file shows:
    *** 2006-11-08 10:06:47.154
    *** SERVICE NAME:(SYS$USERS) 2006-11-08 10:06:47.147
    *** SESSION ID:(379.954) 2006-11-08 10:06:47.147
    qtable move procedure starting execution at 08-11-2006 10:06:47 for queue table XFORM_TEST_INT.INTERFACE_XML_QUEUE
    qtable move procedure experienced an exception at 08-11-2006 10:06:47
    qtable move error message ORA-06502: PL/SQL: numeric or value error
    qtable move procedure ended execution at 08-11-2006 10:06:47
    Can anyone help with this? Has anyone used this before successfully (or not successfully). We urgently need this working today to test moving our queue table into a tablespace with a smaller block size for performance reasons in production.
    Thanks for the help!
    Tony

    Thank you,
    Yes we've done that. They've confirmed a problem with the links/scripts on the note. The 10.1 and up version was not really 10.1 and up.
    As they would not have a new version available in time for the move we needed to perform, we switched our approach to using dbms_redefinition instead.
    Thanks for the reply,
    Tony

  • Alternate fact table without disturbing the existing fact table in EIS

    I have a question in EIS, how to load or work with alternate fact table, without disturbing the existing fact table, pls provide me with some procedure and steps
    thank u in advance
    sunil

    Yes you can have multiple models and metaoutlines load one cube. I've done it before. The trick is you ahve one "master" metaoutline that you put all the measures in (even if they are manually added. You use that to build the cube. Then you can have multiple metaoutlines build different measures within the cube. The idea is you have to have them update different intersections or the last one in will be what you get. I have a client that gets sales info from one source, shipment info from a different relational source . in all I have 10 differnt models and metaoutlines that build one cube. you just lump the load statements into one CBS file. It works great (or as great as EIS works). The biggest issue is timing to make sure all the sources are available when the load is going to be doe. Of course you could build different parts at different times.

  • How can i transfer videos without losing the sound to my iPhone 3G?

    Hi
    I have bought my iPhone 3G yesterday. I have found out how to transfer music from iTunes however i can't transfer videos. I'm selecting the videos i want to transfer on the videos tab after i chose my iphone from the side menu and pressing apply. iTunes says that its syncing my iphone but it doesnt transfer the videos.
    Lately i have found out a function on the advanced menu for movies as "create iphone or ipod version". When i used that it transfered that video to my iPhone however the sound was completely lost besides that action takes too much time(around 10 mins for a 3 min video and i have a pretty strong computer).
    How can i transfer videos without losing the sound to my iPhone 3G?

    One thing I'd recommend is that you make sure the video/audio you're trying to transfer falls within the guidelines listed in the 'Video' section here:
    http://www.apple.com/iphone/specs.html
    What's most likely happening is that the file is not converted as such so when you try to transfer it, it's wanting to convert it but is unable to for any number of reasons.
    There's software out there that might make this easier for you but I can't recommend anything specifically.

  • HT201363 My iPhone, iPad and iPod are all associated with the same Apple ID.  How can I remove the iPod and associate it with a new Apple ID without affecting the data on the other devices (note: there is no data on the iPod I want to keep)?

    My iPhone, iPad and iPod are all associated with the same Apple ID.  How can I remove the iPod and associate it with a new Apple ID without affecting the data on the other devices (note: there is no data on the iPod I want to keep)?

    Very simple.  Turn off Find my iDevice, then  Tap Settings, General, Erase, Erase all content and settings.

  • Transaction data can be loaded into the Fact table without loading the

    Transaction data can be loaded into the Fact table without loading the corresponding master data (Example : Sales analysis transaction data can be loaded without populating any of its  dimension’s master data)
    a.     True
    b.     False

    Hi Kutti,
    True - You need to select the option in the infopackage - alwyas load even if no master data exists.
    Bye
    Dinesh

Maybe you are looking for

  • Open document from a webfolder

    Hi. I have got a procedure which writes BLOBS to a directory onto Oracle XDB (for example ms office docs). /public/docs/test.doc Is there a pl/sql package for opening the file test.doc in ms word so that the user can directly edit the document in XDB

  • In upgrading to OSX 10.9.2 I lost my keynote what can I do

    After installation, I am unable to locate my KeyNote application? Where did it go? How do I retrieve it?  Seems a high price to pay just ot upgrade to the latest OSX. Everything else seems to be there along with some new applications. 

  • I am unable to re-install itunes due to an Error 2

    I have tried to uninstall and re-install itunes using the troubleshooting tips for windows 7 but I'm still having some problems. After I download it, a message pops up saying Apple Mobile Device failed to start and to verify if I have suffient privil

  • Applying changes to stacks, counter intuitive?

    Help says: Here are a few tips for working with stacks: Any develop adjustments, ratings, flags, or color labels applied to a collapsed stack affect only the top photo. If you select a photo in a stack and add it to a Quick Collection or collection,

  • Third Party Order Planning with SNP - Forecast not Consumed

    Hallo SAP Gurus, I have implemented the solution "Third Party Order Planning with SNP" created by Abhay Kapase in our SAP APO System - please see http://scn.sap.com/community/scm/apo/blog/2014/02/26/third-party-order-planning-with-snp. But I have one