Looping over multiple rows of data to output one row

My query is giving me the appropriate data, but I need to
only have one row per 'MANAGER' in my output - not one for each
'JOB'. Now the output looks like this:
manager 1 ... period 1 $ .... period 2 $ .... period 3 $
manager 1... period 1 $ .... period 2 $ .... period 3 $
manager 1... period 1 $ .... period 2 $ .... period 3 $
manager 1... period 1 $ .... period 2 $ .... period 3 $
manager 2... period 1 $ .... period 2 $ .... period 3 $
manager 2... period 1 $ .... period 2 $ .... period 3 $
manager 2... period 1 $ .... period 2 $ .... period 3 $
manager 2... period 1 $ .... period 2 $ .... period 3 $
It needs to be:
Manager 1 ... total period 1 $ .... total period 2 $ ....
Manager 2 ... total period 1 $ .... total period 2 $ ....
Any help would be wonderful. I am really new at something
this complex. Thanks!!!

To fix your immediate issue, you need to order and group by
manager, not MPR_ID (whatever that is).
What is dm_id? Use descriptive names!
Anyway, change the ORDER BY clause to:
ORDER BY
RR.LastName+', '+RR.FirstName, <!--- Or maybe dm_id??
--->
AA.MPR_ID
Then change the first <cfoutput> to:
<cfoutput query="production" group="Rep_name">

Similar Messages

  • Looping over arraycollection with sap data

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

  • OCI8 OCIBindDynamic failure to callback on random columns over multiple rows

    I am developing a set of bindings to Oracle for Python; see http://www.zope.org/Members/matt/dco2
    When attempting to implement Python's executemany() method of the Python DB API, the code sets up a set of columns which are marked as DATA_AT_EXEC when bound, and a subsequent OCIBindDynamic is issued to set up the input callback.
    This works, and I can have multiple rows retrieved in this fashion, EXECEPT that sometimes, Oracle does NOT call back a column, and will attempt to insert NULL for this column instead. The row/column for which this happens is apparently random, and the incidence of this is timing related (reducing the batch size also helps).
    Has anyone got any idea if this is a legitimate bug in the transport interface? I have trace tables in my bindings which clearly demonstrate that a callback does NOT occur on random columns.

    I've seen this problem with 8.0.5, 8.1.6, 8.1.7 on Linux (I test on 4 different machines, with various distributions), and 8.1.7 on Solaris.
    I am interested in trying to keep things bound DATA_AT_EXEC to keep the code paths simplified, so I'd like to figure it out and fix it.

  • Multiple events per date with only one photo each - Unwanted

    I have the eyefi wireless sd card in my camera and it is setup to transmit my photos into iphoto automatically, which it does. However, the problem arises in that iphoto creates multiple events for the same date each containing only one photo. I would prefer that iphoto create individual events per date and have the multiples of that date's photos within. I thought I had the settings configured to do so as I have preferences set for autosplit events one per day but I still see events such as - July 3, 2008 - July 3, 2008 - July 3, 2008 - each with only one photo inside.
    I am wondering if it is something in iphoto's settings or the way in which eyefi transmits the photos into iphoto.
    Any thoughts?

    I do not have a WiFi connection to my camera so can not test but am just guessing
    I can think of two possibilities
    - 1 - if you are taking the photos with the WiFi connected then each time you snap a photo it may be being sent which would be looked at as a new import and therefore create a new event - to stop this I believe you would have to not have a full time WiFi connection to your camera or somehow set the camera to send batched - not each one - iPhoto will take each batch into and follow the rules for making events for that batch even if you camera is sending many batches of One photo
    - 2 - You have the preference for making batches set to one every two hours and there is a long time between photos - I'm guessing that #1 is more likely
    LN

  • Best way to loop through multiple rows to search for a count result

    I have a script where I'm trying to find a Rollup row without any children. I have created a SQL statement to do this, but I can only input one point at a time. If the count is greater than 0 then i'm good to go. If the count is 0 then I want to know about it.
    select count (*) from (Select * From ESSBASE_FCS.Ham
    where hier_pt like (Select substr(hier_pt, 1,8)||'%' as hcy_pt
    From ESSBASE_FCS.Ham
    Where Hier_Pt = '412375....')
    And Cctr_Or_Rollup 'Rollup')
    What is the best way to develop a SQL script that searches through all my Hier_pt's and return everything with a count of 0, instead of manually inputing each hier_pt at a time?
    Thanks for any help.

    Hi,
    Please read SQL and PL/SQL FAQ
    Please provide table structure, sample data and expected output.
    Additionally when you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    I noticed also that you have posted the same question here: {message:id=10678000}
    If you move your question to another forum please mark the previous question as answered.
    Regards.
    Al
    Edited by: Alberto Faenza on Nov 7, 2012 5:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Perl API: growing memory problem in loops over large sets of data

    Hi,
    When going through all XmlResults like this:
    while ($results->next($val)) {
    print $val->asString, "\n";
    The process size keeps growing. It does not when I comment $val->asString method out, but then I have no way of getting the results.
    This becomes a significant problem when the number of results is huge. I am doing this on a database of over a million short XML documents (400-800 bytes each).
    The more complete code is here:
    eval {
    $env = new DbEnv();
    $env->open($dbDir, Db::DB_JOINENV | Db::DB_INIT_LOCK
    | Db::DB_INIT_MPOOL | Db::DB_CREATE, 0);
    my $mgr = new XmlManager($env, DbXml::DBXML_ADOPT_DBENV);
    my $db = $mgr->openContainer(undef, $dbName, Db::DB_RDONLY);
    my $context = $mgr->createQueryContext(XmlQueryContext::LiveValues,
    XmlQueryContext::Lazy);
    my $lookup = $mgr->createIndexLookup($db, "", $nodeName,
    "node-$nodeType-equality-$syntax",
    new XmlValue($types{$nodeType}, $value), XmlIndexLookup::GTE);
    my $results = $lookup->execute(undef, $context);
    my $val = new XmlValue();
    while ($results->next($val)) {
    print $val->asString, "\n";
    if (my $e = catch std::exception) {
    die $e->what() . "\n";
    The process size just grows until the system limit is reached, then the process quits saying 'Out of memory'.
    I suspect the problem is with the std::string result returned by C++ XmlValue::asString() const.
    The (left-hand-side) result string is likely allocated by new std::string and receives the value by calling the string copy operator. Then the Perl scalar result is prepared, but when it gets returned to my code, the C++ string is not deleted.
    Moving the Sleepycat::XmlValue Perl object inside the loop does not help either:
    while ($results->hasNext()) {
    my $val = new XmlValue();
    $results->next($val);
    print $val->asString, "\n";
    In fact, the process seems to grow faster, possibly because the old $val instances do not get destroyed by Perl at the end of the loop. Where is Perl's garbage collection?
    I am using DB XML version: 2.2.13; BDB version: 4.4.20.2; OS: FreeBSD 6-STABLE. However the problem seems to be common for any OS or BDB XML version as it involves Perl-to-C++ interface.
    Has anyone experienced similar problems?
    Thanks,
    Konstantin.
    Konstantin @ Chuguev.com

    Good catch - you found a memory leak. Luckily the fix is very straightforward. Edit the file
    dbxml/src/perl/common.h
    and find this line
    #define newSVfromString(str) newSVpvn(str.c_str(), str.length())
    Change it to this
    #define newSVfromString(str) sv_2mortal(newSVpvn(str.c_str(), str.length()))
    and recompile the module.
    Paul

  • Merge multiple source table dates and to one target table

    The requirement is to merge multiple source tables (each table has a set of start and end date) to one target table with one set of start and end date and contain the date relevant column values from each source table.  Payment source tablestart dateend datepayemnt1/1/201512/31/2015301/1/201612/31/999960Position source tablestart dateend dateposition1/1/201512/31/2016101/1/201712/31/999920Target tablestart dateend datepayemntposition1/1/201512/31/201530101/1/201612/31/201660101/1/201712/31/99996020 What transformation(s) will be best to use to handle this requirement? Thanks, Lei

    Thanks Karen,
    that was exactly what i was hoping for.
    Maybe it could be made easier/less confusing if the Mapping Workbench just made you choose a target table. But maybe this is not usefull if the table contains two foreign keys to the same table. Or maybe this should just be put somewhere in the documentation.
    Regards,
    Robert
    Hi Donald,
    fortunately i'm my own DBA so i don't have any problems ;-). However i'm certainly interested in the reasons for not having such a conditional foreign key.
    However actually the foreign key isn't conditional, the condition is that either the field (using the FK) must be filled, or a free-format field. The reasoning for this is that we have a list of known towns and if the addres is local a town from that list must be chosen. If the addres is outside the country a town can just be typed in (no list).
    Concerning the agrregate, all fields are always used. There are no neediness flags anywhere. The aggregate contains three fields which are mapping as direct (two fields) or a One-to-one (the FK). All 'parents' all contains these three fields.
    Regards,
    Robert

  • Looping over query by month

    etings,
    I have a query I am pulling that has a date field entitled, "Completed". I am attempting to loop over the query by date to slice and dice the data for a table and chart. Here is what I have done thus far...
    Setup two variables where I am only interested in the month. My plan is to fileter the date by month so I can pull the data out by month.
        <cfset startDate = #DatePart('m','01/01/09')#>
        <cfset endDate = #DatePart('m',Now())#>
    Here is my loop...
        <cfloop from = "#startDate#" to = "#endDate#" index = "i" step = "1">
    Here is one of my QoQs within the loop...
            <cfquery name="NPS0" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE #DatePart('m',rsNPS.completed)# = #i#
            </cfquery>
    I am having difficulties in getting this to work. Has anyone ever done something like this. I feel like the answer is right in front of me, but I have been staring at this code for a while. If anyone has any thoughts, I would be glad to hear them.
    ~Clay

    fs22 wrote:
             <cfquery name="NPS0" dbtype="query">
            SELECT *
            FROM rsNPS
            WHERE #DatePart('m',rsNPS.completed)# = #i#
            </cfquery>
    QoQ are a separate beast. You cannot use standard CF functions inside them.  AFAIK, QoQ only support a few functions like CAST, UPPER, LOWER, etcetera.  So as Dan suggested, you should peform the date functions in your database query.

  • How can I have multiple fields on the left and one large field on the right?

    I'm trying to conserve space on a form.  I have five "pass/fail" fields on the left and would like a large free text field to the right.  This will be an area to comment on the "pass/fail" section.  When I add the multi-line text box, it moves all my "pass/fail" mulitple selection boxes.
    Any advice?

    Sorry FormsCentral doesn't allow a fields to spam over multiple rows.
    Gen

  • Need to output data to TXT with static header and footer but multiple rows

    Using APEX 4.0 and 11g - The only way I could find to get data out of APEX in TXT format was to use htp.prn. I load a cursor with the data and this works fine, the problem is that I need to have the file start with a string (*:P9_HEADER_STRING*) but it can only appear once in the output.
    Is there a way to add the *:P9_HEADER_STRING* to the output in a single TXT file? or is there another way I should be doing this?
    This is what I have now: The *:P9_HEADER_STRING* is in the loop which I know it can't be, but I can't figure out how to concatenate this string to the output from the loop. The rank() is being used because I can only send the selected number of records, ranked from highest. (I will have to do the same thing with a footer too, but that variable isn't in here yet)
    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Loop through all rows in CLIENT_TABLE
    for x in (select * from (select XREF_NBR
    , TOT_AMT
    , '' SPOUSE_INFO
    , '' PHONES
    , NAME
    , SURNAME
    , '' MARITAL_STATUS
    , '' EMPLOYER_INFO
    , GENDER
    , '' CO_ADDRESS
    , '' PREV_ADDRESS
    , POSTAL_CODE
    , ADDRESS1
    , '' FILLER
    , rank() over (order by tot_amt desc, rownum asc) rn
    from client_table c where c.File_Seq_Nbr is NULL and c.xref_nbr in (select xref_nbr from ticket_table where to_char(ticket_issue_date, 'YYYY-MM-DD') between :P7_START_DATE and :P7_END_DATE))
    where rn <= :P7_NUMBER_RECORDS)
    loop
    -- Print out a portion of a row,
    -- separated by commas and ended by a CR
    htp.prn( *:P9_HEADER_STRING* || '03' || lpad(X.XREF_NBR, 12) || lpad(x.TOT_FINE_AMT, 11, '0') || '0201'|| lpad(x.NAME, 30) || lpad(x.SPOUSE_INFO, 60) || '00000000000000000000'|| x.DATE_OF_BIRTH || '0000000000000000' || x.GENDER || x.MARITAL_STATUS || lpad(x.EMPLOYER_INFO, 60) || lpad(x.CO_ADDRESS, 102) || lpad(x.ADDRESS1, 30) || lpad(x.POSTAL_CODE, 9) || lpad(x.FILLER, 21) );
    end loop;
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    end;

    Yes, I've already done that, hence this part of the code I pasted above:
    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Loop through all rows in CLIENT_TABLE
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    end;
    I've solved my problem by loading the cursor data into a variable (inside the loop) and concatenating the header info to it (outside the loop). This works when there are only a few records but as soon as I get to 32767 bytes it's throwing an error because of the size. So that's a different issue altogether.

  • Merging multiple rows into a string without loop

    Hi,
    Wanted to know if there is a way we can merge the result set for a query(single column) into a string ?
    For example, I have the following query which returns multiple rows:
    SELECT organization_code
    FROM mtl_parameters
    WHERE oganization_id IN ( 1,2,3)
    Lets say the result set for this is :
    A
    B
    C
    I want the data as A,B,C
    Basically I will be fetching the organization_ID from a diff sub query. I know I can do it using for loop and keep appending the values.
    But wanted to know if there is any easier way of doing it.

    Try this
    SELECT ''||SUBSTR (SYS_CONNECT_BY_PATH (organization_code , ','), 2)||'' csv
          FROM (SELECT organization_code
    , ROW_NUMBER () OVER (ORDER BY organization_code
    ) rn,
                       COUNT (*) OVER () cnt
                  FROM mtl_parameters
    WHERE oganization_id IN ( 1,2,3)
         WHERE rn = cnt
    START WITH rn = 1
    CONNECT BY rn = PRIOR rn + 1;

  • Splitting comma seperated column data into multiple rows

    Hi Gurus,
    Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
    Below is the example:
    Source Data:
    Product         Size                                 Stock
    ABC              X,XL,XXL,M,L,S                 1,2,3,4,5,6
    Target Data:
    Product         Size                                 Stock
    ABC              X                                     1
    ABC              XL                                   2
    ABC              XXL                                 3
    ABC              M                                    4
    ABC              L                                      5
    ABC             S                                        6
    Which transformation we need to use for getting this output?
    Thanks in advance !

    Hello,
    Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
    Thanks

  • Oracle query - Merging multiple rows into a single row output

    Hi All,
    I have to have a multiple row output to be converted into a single row output.My current output looks as follows:
    ID YR INC_CODE OFFN SCHOOLNO
    8006 2002 00175 SC03 12
    8006 2002 00175 DC06 12
    8006 2002 00175 DC03 12
    8006 2002 00175 DC02 12
    ID,INCIDENT CODE,OFFENSE are all Primary keys
    So I need the output as follows:(IN ONE ROW)
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 SCHOOLNO
    8006 2002 00175 SC03 DC06 DC03 DC02 12
    Can you help me on this since have been spinning the wheel and this has to be a query since will have couple of tables join to produce a materialized view.
    Thanks in advance

    Hi Nigel,
    Thanks for the reply I tested out the portion having the decode and I get the output as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 -----------------------
    8982 2002 2175 DOC02-------------------
    8982 2002 2175 DOC03------------
    8982 2002 2175 DOC06-------
    8982 2002 2175 SCV03
    There is no value as max for OFFN and each INC_CODE MAY HAVE UP TO A MAX OF 5 OFFN.My query is as follows:
    select distinct STU_STUDENT_ID, INC_BEG_SCH_YR,INC_INCIDENT_CODE
    , decode(rank() over (partition by INC_CODE order by OFFN),1,OFFN,null) as offn1
    , decode(rank() over (partition by INC_CODE order by OFFN),2,OFFN,null) as offn2
    , decode(rank() over (partition by INC_CODE order by OFFN),3,OFFN,null) as offn3
    , decode(rank() over (partition by INC_CODE order by OFFN),4,OFFN,null) as offn4
    , decode(rank() over (partition by INC_CODE order by OFFN),5,OFFN,null) as offn5
    from stu_offn where
    stu_offn.ID = '8982' and stu_offn.INC_CODE = '2175'
    (****Where clause is just given to just check a value)
    So as you know I need to just have all the OFFN in a single row ie as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 DOC02 DOC03 DOC06 SCV03
    Can you just give me a step by step procedure to go through this and the table in this case is just 'STU_OFFN'
    Thanks for the earlier reply appreciate it!
    ****Sending this again to show the exact way the output is coming

  • RFC XI JDBC to external database.... Get data in multiple rows

    Hi,
    We have been really struggling with this scenario. We have created a RFC that has 1 Import parameter (Order_ID) and table parameter (3 Columns: Order_ID, Partner_type, Partner_no).
    When we call this RFC in SAP, it should make a connection to external database via JDBC and get multiple row data for every Order_ID. We are not using Oracle Stored Procedure, instead we are using simple Select statement. Did all the mapping and configured correctly. However, we are getting short-dump when we execute RFC. When we checked in XI, it says " Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd at "
    Has anyone tried getting multiple row information from external database(Oracle) using Select statement in XI ? IF so, can you pl let us know if we need to something different in Mapping ?
    Niranjan

    Niranjan,
    Check this blog of mine to see how the datatype for Synchronous Select should be constructed,
    https://weblogs.sdn.sap.com/pub/wlg/3928. [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    If this looks good, a few checks
    1. Check the request inbound payload , i.e the RFC request in MONI. Is this as expected?
    2. Check the output of the request mapping and check if this is as expected.
    3. Check the response from JDBC, is this as per the datatype defined.
    4. Check the mapping from JDBC response to RFC response.
    To me this looks like an issue with the JDBC response structure.
    Meanwhile to understand how to test mapping, check blog of michal,
    /people/michal.krawczyk2/blog/2005/09/16/xi-how-to-test-your-mapping-in-real-life-scenarios
    Regards
    Bhavesh

  • How to retrieve the multiple rows data on PDF form in a web service method using WSDL DataConnection

    How to retrieve the multiple rows data on PDF form in a web service method using WSDL DataConnection.
    I have a multiple rows on PDF form. All rows have 4 textfields. I want to submit the multiple rows data to a method defiened in webservice.
    Unable to retrieve the data in multiple rows within webservice method.

    Hi Paul,
    I'm now able to save the retrieved xml in a hidden text field and create dynamic table, and I'm able to fill this table from the XML, but the problem is that I could not find the correct way to loop on the xml, what I'm trying to say, the table will have number of rows with the data of the first row only, so can you tell me the right way to loop on the xml!
    this is my code
    TextField1.rawValue=xmlData.document.rawValue;
    xfa.datasets.data.loadXML(TextField1.rawValue, true, false);
    for(var i=0; i<count; i++)
    xfa.form.resolveNode("form1.P1.Table1.Row1["+i+"].Num").rawValue = xfa.datasets.data.record.num.value;
    xfa.form.resolveNode("form1.P1.Table1.Row1["+i+"].Name").rawValue = xfa.datasets.data.record.name.value;
    Table1.Row1.instanceManager.addInstance(true);
    Thanks
    Hussam

Maybe you are looking for