BizTalk mapper - sum over a group

I'm working on EDI 820, need to create a map for integration to our ERP. If we have two payments against one invoice, I need to combine them, basically, group the amounts by invoice. So at the input I'd have:
<ns0:ENTLoop1>
<ns0:RMRLoop1>
- <ns0:RMR>
  <RMR01>IV</RMR01>
  <RMR02>100139196</RMR02>
  <RMR04>4613.00</RMR04>
  <RMR05>4755.67</RMR05>
  <RMR06>142.67</RMR06>
  </ns0:RMR>
  </ns0:RMRLoop1>
- <ns0:RMRLoop1>
- <ns0:RMR>
  <RMR01>AM</RMR01>
  <RMR02>100139196</RMR02>
  <RMR04>-3299.35</RMR04>
  <RMR05>-3299.35</RMR05>
  </ns0:RMR>
  </ns0:RMRLoop1>
 </ns0:ENTLoop1>
on the output I need to get something like:
-<Apply>
<APTODCNM>100139196</APTODCNM>
<APPTOAMT>1313.65</APPTOAMT>
<DISTKNAM>142.67</DISTKNAM>
</Apply>
so, basically, it's producing a sum, grouped by document number.
How would I accomplish something like this using mapping functoids?

Muenchian Grouping is the pattern you have to use for your requirement. You can either use XSLT completely in your map or use call inline XSLT functoid and create an XSLT template which uses Muenchian Grouping. Use the following as the reference:
Muenchian Grouping and Sorting in BizTalk Maps without losing Map functionalitie
XSLT Muenchian Grouping - BizTalk Complex Transformation
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

Similar Messages

  • Sum based on group by and one condition

    I have a tableof following structure
    Group SubGroup sequence length 
    A         x               1            10
    A         X        
        2            20
    A         X               2            30
    A         X               3            50 
    B         Y               4  30
    B         Y               5            40
    I needa new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row.Sum is sum of lengths where sequence is greater than the current row sequence number and grouping
    group nad sub group
    following is the output i am looking for
    Group SubGroup sequence length   Sum
    A         x               1            10          100(Sum of all the lengths where sesquence > current rows sequence
                                                             and group by group,sub
    group and sequnce) 
    A         X               2            20          50
    A         X   3 30 NULL
    B         Y               4  40 50
    B         Y      5 50 NULL

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. 
    And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have a table of following structure <<
    Your posting is crap! Did you know that GROUP and SEQUENCE are reserved words in SQL? Did you really want to use a CREATE SEQUENCE? Did you know a table has a name and key?? That having a separate “<something>_sub_group” column is so bad a design flaw
    it has a name (attribute splitting)? That “<something>_length” cannot exist without being the length of something in particular? 
    CREATE TABLE Rude_Postings
    (rudeness_grp CHAR(2) NOT NULL
     CHECK (rudeness_grp LIKE '[A-Z][A-Z]'),
     foobar_seq INTEGER NOT NULL
     CHECK (foobar_seq > 0),
     PRIMARY KEY (rudeness_grp, foobar_seq),
     foobar_length INTEGER NOT NULL
     CHECK (foobar_length > 0)
    The foobar_seq simply looks wrong. It was not unique, so it could not be a sequence by definition. I will guess that it is unique within a rudeness_grp. 
    INSERT INTO Rude_Postings
    VALUES
    ('AX', 1, 10),
    ('AX', 2, 20),
    ('AX', 3  30),
    ('AX', 4,  50),
    ('BY', 1 , 30),
    ('BY', 2 , 40);
    >> I need a new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row. Sum [sic: SUM is a reserved word!] is sum of lengths where sequence is greater than the
    current row [sic: tables are sets not files, so there is no ordering and no concept of a current row] sequence number and grouping group and sub group << 
    Here is my guess:
    SELECT rudeness_grp, foobar_seq, foobar_length 
       SUM( foobar_length) 
           OVER (PARTITION BY  rudeness_grp 
                   ORDER BY  foobar_seq DESC
                   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
         AS foobar_length_running_tot
      FROM Rude_Postings;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to map multiple output values to the output schema in biztalk mapper?

    Hi,
    In my biztalk mapper, I am using a "database lookup" functoid which is linked to a "Value Extractor" functoid. A source schema field is linked to the database lookup functoid which is linked to a "Value Extractor" functoid
    which is linked to the destination schema field. After passing the required parameter values in the database lookup functoid (lookup value, conn string, table, column name), I know that the result set may get multiple rows which are transferred to the "value
    extractor" functoid.
    Now what I want is to create a record in destination schema for each row in the result set. My current mapping is as below:
    1) Source record > looping functoid > destination record
    2) Source record field > Database functoid > Value Extractor functoid > dest record field
    but this mapping is giving me only the first value in result set.
    Please help me in this so that my map creates a destination record for each value in the result set.
    e.g. if query [select * from employees where surname='Brown'] returns five records, then I would like five records in the destination schema.
    Thanks
    manibest

    Hi Muhammad Ehsan,
    Thank you for the useful suggestion. however, I have only one difficulty in building your suggested solution. in my query  (select
    * from employees where surname='Brown'), the value of surname is coming from the source schema field which could be different in each source schema record field.
    lets say that source schema instance has 3 records in it as below:
    <Records>
    <Record><Surname>Brown<Surname></Record>
    <Record><Surname>Atkinson<Surname></Record>
    <Record><Surname>White<Surname></Record>
    </Records>
    For each of above records the database query should run with the relevant surname value. if database has 5 records for "Brown", 3 records for "Atkinson" and 1 record for "White" then the destination schema should create (5+3+1) = 9 records in
    total.
    To create a destination canonical schema that works fine, I have to somehow pass this surname value from source schema as parameter so that it uses this value to poll the database and get records. Is there a way I can pass this surname value as parameter
    to the destination canonical schema? Thank you so much for the help.
    manibest

  • How to map an array to fixed fields using Biztalk mapper

    I need to remap an array of objects like this:
        <Root>
          <ListOfObjs>
            <Obj>
              <Attr1>0000</Attr1>
              <Attr2>Hello!</Attr2>
            </Obj>
            <Obj>
              <Attr1>1111</Attr1>
              <Attr2>Hello1!</Attr2>
            </Obj>
          </ListOfObjs>
        </Root>
    in an output like this:
            <Root>
                <Obj1_Attr1>0000</Obj1_Attr1>
                <Obj1_Attr2>Hello!</Obj1_Attr2>
                <Obj2_Attr1>1111</Obj2_Attr1>
                <Obj2_Attr2>Hello1!</Obj2_Attr2>
            </Root>
    So in my XSD schema I have something like this:
    Schema Input
                               <xs:element name="Root">
                                <xs:complexType>
                                 <xs:sequence>
                                  <xs:element name="ListOfObjs">
                                   <xs:complexType>
                                    <xs:sequence>
                                     <xs:element name="Obj">
                                      <xs:complexType>
                                       <xs:sequence>
                                        <xs:element name="Attr1">
                                         <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       <xs:element name="Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       </xs:sequence>
                                      </xs:complexType>
                                     </xs:element>
                                    </xs:sequence>
                                   </xs:complexType>
                                  </xs:element>
    Schema output
                                     <xs:element name="Root">
                                      <xs:complexType>
                                       <xs:sequence>
                                        <xs:element name="Obj1_Attr1">
                                         <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       <xs:element name="Obj1_Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="Obj2_Attr1">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="Obj2_Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       </xs:sequence>
                                      </xs:complexType>
                                     </xs:element>
    In addiction I have to evaluate every single value because when I found some conditions (like if value=0000 output should be NULL).
    What would be the best way to do it? I'm thinking to develop a custom functoid but I'm not sure it would be the best way, probably it could be done even using XSLT inline transforms, can you point me in the best direction?
    Thank you

    Hi,
    You cannot directly map an array output to any single field in BizTalk mapper.
    Couple of options :
    1) create
    the Xslt or inline C# code
    Refer: 
    http://seroter.wordpress.com/2008/10/07/splitting-delimited-values-in-biztalk-maps/
    2) Shankycheil has
    provided a solution to similar requirement in the below link, u can also refer that.
    https://social.msdn.microsoft.com/Forums/en-US/55ec472d-4f34-4057-b1c6-0e50740f0f6e/how-to-itterate-string-array-values-in-biztalk-mapper?forum=biztalkgeneral
    Rachit
    Thank you, I already seen both posts, but I'm not sure they are what I need or I can't understand well how to use them.
    Speaking about the first solution, as I told before, in the example I should have an array already formed and delimited by a char (something like "obj1attr1-obj1attr2-ob2attr1-obj2attr2". In this situation probably this example could be a good
    point to start from, but how to transform my complex input object in a similar formatted string?
    About the second I don't understand well what is the working solution that they have adopted. Is the 4 steps solution suggested by  Shankycheil? If yes, how can I loop between all array elements and extract all their values?

  • Create null message using BizTalk mapper XSLT

    Hi,
    I have a requirement to check if a message contains a certian value, and if so, throw away the message.  Does anyone know how this could be done using BizTalk mapper/ XSLT?  It's an ESB messaging only solution so don;t want to introduce orchestratons
    / c# code.
    In short is field A = 'yes' the message will be thrown away / made null. 
    Thanks in advance.
    GilesB

    If you consider doing this in Receive-side with some pipeline component, I am afraid you can't eat the data at the receive pipeline. For a null returned, I believe at least a empty message would be published to message box.
    Without orchestration, in message-only scenario one option you can consider is using a custom adapter where you can have your logic whether to send a stream/message out or not. Something like:
    public bool TransmitMessage(IBaseMessage msg)
    _terminate.Enter();
    try
    bool logMessages = Convert.ToBoolean(
    GetAdapterConfigValue(msg.Context, "logMessages")
    if ( logMessages ) {
    SystemMessageContext ctxt = new SystemMessageContext(msg.Context);
    //Add your logic using XPathReader - stream based XPath
    //and check whether the message has the value your're looking for
    bool isFound = false;
    if (!isFound)
    string msgData = "";
    StreamReader reader = new StreamReader(msg.BodyPart.Data);
    using (reader)
    msgData = reader.ReadToEnd();
    // discard the message
    return true;
    } finally {
    _terminate.Leave();
    Above is part of the send adapter code where you add your logic using XPathReader - stream based XPath and check whether the message has the value your're looking for. You can use
    null send adapter as refernce and build your logic where it would check for the required value in your custom adapter.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Over head group

    hi guys,
    i created over head key, and over head group.  but in material master record it did not accepted to give that over head group.  what is the configuration it was required.  is it assaign costing sheet, if it is where over head key assaign to costing sheed.
    waiting for result.
    thanqu
    raj
    Moderator: thread locked due to double posting

    Hi,
    By assigning Overhead group to the material master we can pick up that material for overhead calculation as well to have different percentages of overhead. This is being done through Costing Sheet. This overhead group is assigned to overhead key as one to one Then Overhead key shall be assigned to different overhead rates. Thus through one single costing sheet, we can able to bring in overhead for multiple products/material.
    Trust this answers to your query!
    Cheers!

  • Analytical function SUM() OVER (PARTITION BY ) in Crosstab

    I am trying to resolve this from a very long time. I have an amount column that has to be grouped on Year, but all the other columns grouped by month. I am trying to achieve this using analytic function SUM(Case when (Condition1 and Condition2) then Sum(Amount) else 0 end) OVER ( PARTITION BY Account, Year), Where Account, Sub Account are the left axis columns. Now, column displays the values correctly, but at different rows. This is confusing.............
    For Ex: For Account 00001, there are 3 sub accounts 1000,2000,3000. For Sub account 3000, conditions 1 and 2 are satisfied, so it should display the Amount in the row corresponding to Sub account 3000, and 0 for remaining Sub Accounts. And the Total amount of all the sub accounts, which will be the same as amount for SubAccount 3000 should be displayed in the row corresponding to Account 00001.
    But I get blank rows for 1000 and 3000 Sub accounts and Amount displayed in 2000 Sub account, and blank for Account 00001 also.
    When I created the same workbook in Tabular form, the same amount is displayed for all the SubAccounts of a single Account.
    When I used this CASE statement in TOAD, I figured that this is due to the Analytic function. When I use a group by clause as shown below instead of partition by, I get the results I need.
    SELECT (Case when (Condition1 and Condition2) then Sum(Amount) else 0 end), Account, Sub Account FROM tables WHERE conditions GROUP BY Year, Account, Sub Account
    But I cannot use groupby for whole SQL of the workbook as I need the other columns with page item 'MONTH' not 'Year'.
    Could somebody please help me with this?

    Hi,
    In your tabular form do you get the correct total display against all you subaccounts and account? If this correct then you can use case to ensure that the total is displayed only for the single account.
    Once you have the correct totals working in a tabular form it is easier to re-produce what you want in a cross-tab.
    Rod West

  • BizTalk mapper is horrible

    Hello. I want to know if MS plans any improvements in BizTalk mapping? Changes they made in 2010 are laughable.
    My experience with BizTalk mapping starts with 2004 version. But nothing really has changed since that time. And working with maps in BizTalk drives me crazy.
    The problems are:
    1. No reuse at all.
    I don't need to say it's boring to copy paste something from one map into another. But it's more than a boredom - it's against any coding rules. And what if I have 20 maps with copy-pasted block and need to change it?
    Wanna sample? Let's take new CRM (2011). The task is to sync 30 custom dictionaries with other systems. All you can use is late binding (thx MS ;(). Simple drag and drop doesn't work cos u need to map xsi:type attributes on xs:Any elements. The only choice
    is to duplicate xslt scripting functoids over 30 maps..
    2. Bad xslt support.
    Xslt editor in scripting functoid is joke. Every time I want to edit a script I do it in another window of VS..
    3. Custom functoids..
    Why would you create such thing and sandbox it at the same time making it impossible to write anything useful? BaseFunctoid is completely sandboxed. Even with reflection you can't do nothing -it has no references to outworld. If only MS passed there compile-time
    information such as node links and etc, you could do some cool things, but no they didn't.
    And that's only mapping.. Does MS care of BizTalk?

    Thanks for answers. But I can't agree fully agree with your points.
    Although XSLT is great by itself, biztalk puts its own restrictions. xls:import and xls:include don't work in biztalk xslt maps thus leaving you with still no reuse. Using xslt in code with custom resolver gives other challenges like storing and
    resolving xslt in resources, scaleability and other issues.
    I wouldn't be so optimistic about 99% transformations fitting awsome in mapper capabilities. I did no research on that matter, but I feel it's not true. Mapper can do it's job in simple scenarios, being "awesome" in very simple ones (that microsoft love
    to show in demos). But first time you insert inline xslt in your map means you're out of mapper capabilities.
    I agree that if schemas designed well there are less problems. But it's not always the case. Take for instance a good schema reusing a complex type in many elements. What you wanna do is make xslt template for filling such complex type and invoke it
    in your map instead of linking lots of funcdouds and duplicating them all over your map. It's only one example.
    The idea of deriving schemas by replacing those xs:any is interesting. If only it would end with few extra schemas. But making dozens of them is not the kind of job I commited for.
    The thing that makes me angry is that it's not THAT hard to improve mapper. All needed is to make few little changes in right direction. But instead there are interface tweaks.

  • Sum Over Time

    Hi,
    I'm trying to do something which I would guess is quite a common query, but after scratching my head and perusing the web I am still no closer to a solution.
    I am running:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    I'm looking to sum up a set of values, taking into account both a parent grouping and start and end dates.
    For the parent grouping I am using:
    +SUM([value]) over (Partition by [Parent] order by [Parent],[Child])+
    And I was hoping to be able to extend this SUM to also handle the start and end dates, so the final output would contain a sum of the values for each different time period.
    As an example, using the data below I'm trying to sum up the price of the components of a car over time:
    row, product, component, rate, start date, end date
    1, car, chassis, 180, 01/01/2000, 31/12/2009
    2, car, chassis, 200, 01/01/2010, 01/01/2050
    3, car, engine, 100, 01/01/2000, 01/01/2050
    Notice there is a change of price for Component 'chassis', so the output I'm looking for is:
    row, product, component, rate, start date, end date, sum
    1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
    2, car, engine, 100, 01/01/2000, 31/12/2009, 280
    3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
    4, car, engine, 100, 01/01/2010, 01/01/2050, 300
    But in reality all I need is:
    row, product, start date, end date, sum
    1, car, 01/01/2000, 31/12/2009, 280
    2, car, 01/01/2010, 01/01/2050, 300
    Preferably the query would be in a view rather than a stored procedure, and it needs to be able to handle many 'products', 'components' and start/end dates.
    All help most appreciated, and if any more info is required, please let me know.
    Thanks,
    Julian

    Hi Frank,
    Thanks for picking up this query, I'll try to explain my points in more detail:
    +SUM([value]) over (Partition by [Parent] order by [Parent],[Child])+I don't see columns called value, parent or child in the sample data below.
    Is value the same as rate? What are parent and child? In the example:
    Product is the parent
    Component is the child
    Rate is the value
    Whenever you have a problem, post CREATE TABLE and INSERT statments for your sample data.CREATE TABLE "REPOSITORY"."PRODUCT_RATES"
    (     "PRODUCT" VARCHAR2(255 BYTE),
         "COMPONENT" VARCHAR2(255 BYTE),
         "RATE" NUMBER(9,2),
         "START_DATE" DATE,
         "END_DATE" DATE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "SHOP_AREA" ;
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'chassis', 180, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2009','dd-mm-yyyy'))
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'chassis', 200, to_date('01-01-2010','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'engine', 100, to_date('01-01-2000','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
    Although the above short scenario highlights my issue, to expand on the example data set:
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'wife', 500, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2001','dd-mm-yyyy'))
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'wife', 999, to_date('01-01-2002','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'baby', 250, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2004','dd-mm-yyyy'))
    insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'baby', 500, to_date('01-01-2005','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
    Notice there is a change of price for Component 'chassis', so the output I'm looking for is:
    row, product, component, rate, start date, end date, sum
    1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
    2, car, engine, 100, 01/01/2000, 31/12/2009, 280
    3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
    4, car, engine, 100, 01/01/2010, 01/01/2050, 300Explain how you get 4 rows of output when the table contains only 3 rows. Are you saying that, because some row has end_date=31/12/2009, then any other row that includes that date has to be split into two, with one row ending on 31/12/2009 and the other one beginning on the next day?
    Explain, step by step, how you get the values in the desired output, especially the last column.
    But in reality all I need is:Sorry, I can;'t understand what you want.
    Are you saying that the output above sould be acceptable, but the output below would be even better?
    row, product, start date, end date, sum
    1, car, 01/01/2000, 31/12/2009, 280
    2, car, 01/01/2010, 01/01/2050, 300
    Preferably the query would be in a view rather than a stored procedure, and it needs to be able to handle many 'products', 'components' and start/end dates.Include a couple of differtent products in your sample data and results.
    I'm not sure what you want, but there's nothing in what you've said so far that makes me think a stored procedure would be needed.The only output I actually require is:
    row, product, component, rate, start date, end date, sum
    1, car, 01/01/2000, 31/12/2009, 280
    2, car, 01/01/2010, 01/01/2050, 300and with the extended data set:
    3, family, 750, 01/01/2000, 31/12/2001
    4, family, 1249, 01/01/2002, 31/12/2004
    5, family, 1499, 01/01/2005, 31/12/2050however, I was thinking that the data set would need to be somehow expanded to get to the above end result, hence why I included the 'middle step' of:
    row, product, component, rate, start date, end date, sum
    1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
    2, car, engine, 100, 01/01/2000, 31/12/2009, 280
    3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
    4, car, engine, 100, 01/01/2010, 01/01/2050, 300however, this may be irrelevent.
    By the way, there's no point in using the same expression in both the PARTITON BY and ORDER BY clauses of the same analytic function call. For example, if you "PARTITION BY parent", then, when "ORDER BY parent, child" is evaluated, rows will only be compared to other rows with the same parent, so they'll all tie for first place in "ORDER BY parent". OK, thanks.
    So far I have got to:
    select
    sum(rate) over (partition by product) as sum,
    a.*
    from product_rates a
    which results in:
    SUM     PRODUCT     COMPONENT     RATE     START_DATE     END_DATE
    480     car     engine     100     2000-01-01 00:00:00.0     2050-01-01 00:00:00.0
    480     car     chassis     200     2010-01-01 00:00:00.0     2050-01-01 00:00:00.0
    480     car     chassis     180     2000-01-01 00:00:00.0     2009-12-31 00:00:00.0
    2249     family     baby     250     2000-01-01 00:00:00.0     2004-12-31 00:00:00.0
    2249     family     wife     999     2002-01-01 00:00:00.0     2050-01-01 00:00:00.0
    2249     family     baby     500     2005-01-01 00:00:00.0     2050-01-01 00:00:00.0
    2249     family     wife     500     2000-01-01 00:00:00.0     2001-12-31 00:00:00.0
    but this shows that all price variations for a component over time are being summed (e.g. car enging 100 + car chassis 200 + car chassis 180 = 480)
    Hope that goes someway expaling my query better.
    Also, quick query to improve my postings - how do i indent without making text ittallic, and how do you make code a different font?
    Thanks again.
    Julian

  • RTF Template: sums with nested groups

    Hi all,
    i've got quite a pickle of a problem it seems ...
    my data structure looks something like this:
    <COMPANY>
    --<STORE>
    ----<DEPARTMENT>
    ------<ITEM></ITEM>
    ----</DEPARTMENT>
    --</STORE>
    </COMPANY>
    multiple companies can have multiple stores, which in turn have multiple departments, which also in turn can have multiple items.
    my select statement looks something like this:
    select company_id,
    store,
    department,
    item,
    sum(qty) as my_sum
    from
    table_1, table_2, table_n
    where ...
    group by ...
    order by company_id;
    my xml data template grouping looks something like this:
    <group name="G_company" ...
    --<element name="E_company" ...
    --<group name="G_store" ...
    ----<element name="E_store" ...
    ----<group name="G_department" ...
    ------<element name="E_department" ...
    ------<group name="G_item" ...
    --------<element name="E_item" ...
    --------<element name="E_item_total" value="my_sum" ...
    ------</group>
    ------<element name="E_department_total" value="G_item.E_item_total" function="SUM()" />
    ----</group>
    ----<element name="E_store_total" value="G_department.E_department_total" function="SUM()" />
    --</group>
    </group>
    my report currently looks something like:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    if i just focus on the Store --> Department --> Item, i achieved this in my RTF template by doing something like the following:
    <table>
    --<tr>
    ----<td><?for-each-group@column:G_store;E_store?>Store</td><td><?for-each-group@column:G_department;E_department?>Department</td><td><?for-each-group@column:G_item;E_item?>Item<?end for-each-group?> <?end for-each-group?> <?end for-each-group?> </td>
    --</tr>
    --<tr>
    ----<td><?for-each-group@column:G_store;E_store?><?E_store_total?></td><td><?for-each-group@column:G_department;E_department?><?E_department_total?></td><td><?for-each-group@column:G_item;E_item?><?E_item_total?><?end for-each-group?> <?end for-each-group?> <?end for-each-group?> </td>
    --</tr>
    </table>
    as you can see, the store --> department --> item go across the report horizontally.
    my problem is i want to have grand totals for each column, like:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------6------------6---------------7---------------3------------------2-------------------9----------------5-------------------5
    so i did a SUM on each of the E_store/department/item_totals like:
    <?sum(current-group()/E_store_total)?>
    now that works for E_store_total ... but not for E_department_total and E_item_total!
    it seems BI Publisher doesn't like sums used with inner loops.
    because if i extract just the column for E_department, the grand total value at the bottom is correct!
    but once i put back the outer store loop, it breaks.
    what i am currently getting with this is:
    ------------------<b>Store</b>--------<b>Dept</b>---------<b>Dept</b>---------<b>Item</b>-----------<b>Item</b>---------------<b>Store</b>-----------<b>Dept</b>----------<b>Item</b>-----------<b>Item</b>
    <b>Company</b>---Townsville---TDept_1------TDept_2-----TDItm1----------TDItm2-------------Newcastle------NDept1----------NDItm1--------------NDItm2
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    it is doing the grand total for Store correctly, but it just gives me the first row for the other grand totals.
    i have tried:
    1. using the CUBE function in my SQL query, which gives me the results i want with all the totals i want, except i cannot seem to translate it into XML.
    2. trying to use the pivot table option but i can't seem to ever get it to work the way i want.
    3. using a separate sql query to retrieve the grandtotals but that doesn't work either because of the multiple looping required.
    i'm at a complete dead end, any help would be really appreciated!
    ps. i'm a very fresh newbie

    Hi Vetsrini,
    thank you very much!
    when you said to use current-group i was confused because i thought i was using it, but when i opened up the RTF template i realized you meant the actual looping.
    so instead of doing:
    <?for-each-group@column:G_DEPARTMENT;E_DEPARTMENT?>
    <?sum(current-group()/E_STORE_TOTAL)?>
    i should have been doing:
    <?for-each-group@column:current-group()//G_DEPARTMENT;E_DEPARTMENT?>
    <?sum(current-group()/E_ITEM_TOTAL)?>
    thanku!
    S.

  • Can I mouse over a group and cause another group to do something?

    When I mouse over id=wholeGroup, I want group rect47 to become more visible by changing its alpha value.
    Can someone help me understand how to do this? Thanks.
    Here is what I have so far, but I am getting multiple errors.
    1067: Implicit coercion of a value of type String to an unrelated type Number.
    1119: Access of possibly undefined property mouseOver through a reference with static type spark.components:Group.
    <fx:Script>
      <![CDATA[
         private function showYourSelf():void {
              if (wholeGroup.mouseOver==true) {
                   rect47.alpha="1.0";
               } else {rect47.alpha="0.3";}
      ]]>
    </fx:Script>
    <s:Group id="wholeGroup" mouseOver="showYourSelf()" >
      <s:Group id="rect47">
          <s:Rect>
             <s:fill>
                  <s:SolidColor color="0x474747"/>
              </s:fill>
         </s:Rect>
      </s:Group>
      <s:Group id="rect87">
         <s:Rect>
             <s:fill>
                  <s:SolidColor color="0x878787"/>
              </s:fill>
         </s:Rect>
      </s:Group>
    </s:Group>

    Change the strings to numbers:
    rect47.alpha=1.0;
    <s:Group id="wholeGroup" mouseOver="showYourSelf()" mouseOut="hideYourSelf()">
    In the function showYourSelf() just set rect47.alpha=1.0
    In the function hideYourSelf() set rect47.alpha=0.3
    No need for the if statement.

  • Can't draw connection from anything to destination schema in BizTalk Mapper

    I'm new to BizTalk, so forgive me if I'm not using the correct terminology.  Anyways, I've created a composite Schema with two tables that I'd like to insert into, it's basically like this:
    <xs:element name="StorageLocationImport">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="mxstoreloc:Insert" /> 
                <xs:element ref="mxin:Insert" /> 
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    In the mapper, I'm able to map anything to `mxstoreloc:Insert` with no issue.  When I try to map **anything** to `mxin:Insert`, the connection doesn't work.  I drag the line, I get the crosshairs cursor (I've seen people before get the crossed-out-circle
    cursor, mine doesn't switch to that) and then when I let go the line disappears instead of connecting.
    I went into the schema and created a second `mxin:Insert` node, so it looked like this:
    <xs:sequence>
    <xs:element ref="mxstoreloc:Insert" />
    <xs:element ref="mxin:Insert" />
    <xs:element ref="mxin:Insert" />
    </xs:sequence>
    And for some reason that allowed me to make the connection (to either element), but if I deleted either of the two, the connections would disappear.

    I was able to figure out the solution.  The issue [mostly] lies within the map itself, not either of the schemas or connections.
    In the `Grid Properties` window, by default, `Ignore Namespaces for Links` is set to `True`.  Since I have multiple elements which are named `Insert`(even though the namespaces are different), the XML Mapper gets confused.  To fix this, simply turn
    `Ignore Namespaces for Links` to `False`.

  • Hover mouse over a group photo & individual image pops up?

    My project is to do a mouse hover over individual faces on a group photo and display an image of what that person looked like back in high school.
    So far I am able to display the persons name as I hover over their face but don't know how to also display their individual image.
    I set up an image map with circular hotspots for each face.
    Please visit www.phsclassof1956.com/50th_group.html
    Any help would be appreciated.

    You could do this very easily with Tooltips on an Image Map.  See example below and mouse over Image Map of South America.
    http://alt-web.com/testing.html
    Scripts and documentation here:
    http://www.walterzorn.com/tooltip/tooltip_e.htm
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Calling Business Rules in Biztalk Mapper Extension

    Hi,
    We have BizTalk map which uses Custom XSLT & Custom extension xml. From the mapper extension class file we are executing policy like below.
    public string GetQRDAInfo_MeasureGuid(string pMeasureId)
    {        return CallQRDA_GUID(pMeasureId).CnefMeasure ?? string.Empty; 
     private QRDA_GUID CallQRDA_GUID(string pMeasureId, int pLoop = 1)
     var qrda = new QRDA_GUID(pMeasureId, pLoop);
    using (var policy = new Policy("MU-QRDA_GUID"))   
    policy.Execute(qrda); 
     return qrda; 
    & in XSLT 
     <ns0:QRDA3 xmlns:ns0="http://Foundation.Canonical.Schemas.MeaningfulUse">
          <xsl:attribute name="MeasureID">
           <xsl:value-of select="$measureId" />
          </xsl:attribute>
          <xsl:attribute name="MeasureGUID">
            <xsl:value-of select="ScriptNS0:GetQRDAInfo_MeasureGuid($measureId)"
    />
          </xsl:attribute>
    But I am not getting GUID in my output message.
    Regards,
    Lakshmi

    Well, ok.  How have you tried to debug this?
    I also have to ask, because this seems like an unusual usage for the BRE, why are you using a Policy?

  • SUM over more than 1 column

    Hi,
    I want to summate the values in more than 1 column. My code is like this
    SELECT SUM(Column_A + Column_B) AS Column_C FROM TABLE GROUP BY ID
    but this doesn't work.
    I also tried
    SELECT SUM(Column_A & Column_B) AS Column_C FROM TABLE
    doesn't worked either ...
    Any ideas?
    Greetings from Germany
    Lars

    You may have NULL values in those columns:
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, 1 a,  10 b  from dual union all
      3    select 100,    2,    20    from dual union all
      4    select 100,    3,    null  from dual union all
      5    select 100,    null, 40    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(a + b) AS c
      9    FROM t
    10   GROUP BY ID;
             C
            33
    1 row selected.
    test@ORA10G>You probably want to see 76 here. So -
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, 1 a,  10 b  from dual union all
      3    select 100,    2,    20    from dual union all
      4    select 100,    3,    null  from dual union all
      5    select 100,    null, 40    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(NVL(a,0) + NVL(b,0)) AS c
      9    FROM t
    10   GROUP BY ID;
             C
            76
    1 row selected.
    test@ORA10G>
    test@ORA10G>If you simply get a NULL, I'll bet you have NULLs for all records in both those columns.
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select 100 id, null a,  null b  from dual union all
      3    select 100,    null,    null    from dual union all
      4    select 100,    null,    null  from dual union all
      5    select 100,    null, null    from dual union all
      6    select 100,    null, null  from dual)
      7  --
      8  SELECT SUM(a + b) AS c
      9    FROM t
    10   GROUP BY ID;
             C
    1 row selected.
    test@ORA10G>Use NVL. Make life easy.
    isotope

Maybe you are looking for

  • HELP!!!!  I get the folder with a ? in the middle of the screen...

    In preparation to sell my refurbished iMac Power PC G4, I hooked it up to my new mac, started it in Target Mode, and did a 7-pass erase using the Disk Utility. When I went to start my iMac G4, I got the folder with the ?. In attempting to do some res

  • Wireless keyboard function keys

    Hi, After replacing the batteries of my wireless keyboard I can no longer use any of the mac-specific functions of the function keys (adjusting volume, brightness, etc). I've checked this and other forums and have found people experiencing similar pr

  • I don't want to open certain tabs when starting FF

    I'm using a PC in a different environment and when I start FF 6.0 a couple of Tabs open that I no longer need. How do I stop FF from opening those Tabs? Thanks, John

  • Scheduled CR not changing parameter value in Infoview or CMC

    Hello: I have a crystal reports build with CR 2008 SP2, FP 2.3; that is based on BEx Query with 3 sap bw variables. When refreshing the report in CR Designer, I can change the parameter value and get the right results. When in Infoview or CMC I can r

  • Concurrent execution of mapping

    Hi All, I have quick question about concurrent execution of mapping. Let's assume a simple mapping loading data from external table to regular table. My question is whether it is possible to execute concurrently this mapping but with different set of