How to implement this logic in odi

suposse my table is like this
a b c
1234 01-JAN-09 0
1234 02-JAN-09 1
1234 05-JAN-09 1
1244 06-JAN-09 1
1234 10-JAN-09 0
1234 13-JAN-09 1
1234 25-JAN-09 0
1234 27-JAN-09 1
1234 30-JAN-09 1
1235 01-JAN-09 1
1235 02-JAN-09 0
1235 05-JAN-09 1
1245 06-JAN-09 1
1235 10-JAN-09 1
1235 13-JAN-09 3
1235 25-JAN-09 2
1235 27-JAN-09 0
1235 30-JAN-09 0
i want out put like this
a b c
1234 01-JAN-09 0
1234 02-JAN-09 1
1234 05-JAN-09 2
1244 06-JAN-09 3
1234 10-JAN-09 3
1234 13-JAN-09 4
1234 25-JAN-09 4
1234 27-JAN-09 5
1234 30-JAN-09 6
1235 01-JAN-09 1
1235 02-JAN-09 1
1235 05-JAN-09 2
1245 06-JAN-09 3
1235 10-JAN-09 4
1235 13-JAN-09 7
1235 25-JAN-09 9
1235 27-JAN-09 9
1235 30-JAN-09 9
to get out put like that iam using this query
select a,b,sum(c) over(partition by a order by b) from table.
how to implement "sum(c) over(partition by a order by b)" in odi interface mappings

Hi
if you don't want to aggregate try to define a user function
analytic_sum($(value))
implémented by
sum($(value))
after that
replace your
sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
by
analytic_sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)

Similar Messages

  • How to implement this logic in the discoverer...

    select test_emp.status
           from test_emp te
           where not exists (select 'x' from test_emp b
                                   where  te.job = b.job                    
                                     and     te.sname = b.same              
                                     and     b.sdate > trunc(sysdate));

    You could try creating a calculation like:
    max(sdate) over (partition by job, sname)then creating a condition like:
    <calculation> > trunc(sysdate)

  • How to implement this aggregate logic at target column in odi inteface mapp

    sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
    how to implement this aggregate logic at target column in odi inteface mappings

    Hi
    if you don't want to aggregate try to define a user function
    analytic_sum($(value))
    implémented by
    sum($(value))
    after that
    replace your
    sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
    by
    analytic_sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)

  • How can I implement this logic

    Hi,
    I have 3 input parameters. One is a random value .
    Inside a loop I read this random value . bsed on this value I would like to select between the other parameters.Let me use an example.
    X is the random value. Y and Z are the other 2 parameters. 
    1- In the first iteration if X is greater than previous X , I would like to show the value of Z
    2- In the second iteration If X< greater than preious X then I would like to keep showing Z if not I show Y
    3-  ( lets say we are showing y) In the 3rd iteration If X< greater than preious X then I would like to keep showing Y if not I show Z
    So as said the value of X is used to toggle between Z and Y so when the condition is met we keep showing y or Z if not we show the other parameter.
    Could you please help me to implement this logic in LV
    Thanks

    You only need a shift regsiter with a single output, your solution seems a bit convoluted.
    Anyway, if you want to switch whenever the comparison is false, here's what you would do. Modify as needed.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Switch ValueMOD.vi ‏10 KB

  • In this report i have marked one line..if this width 30,i need to multiply by a number 0.3 and if the width =30,it multiplies by 0.37...how to use this logic here..??? anyone can help??

    In this report i have marked one line..if this width < 30,i need to multiply by a number 0.3 and if the width >=30,it multiplies by 0.37...how to use this logic here..??? anyone can help??
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    Declare @SCCode nvarchar(30)
    select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
    select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
    --Rcpt from PRDN (Condition checked for Return component exclusion also)
    SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
    T2.DocNum AS 'WorkOrderNo',
    b.DocNum as 'Issue Doc No',
    ISNULL(d.DocNum,'') as 'Receipt Doc No',
    b.U_IssPSCName as 'SubContractor Name',
    T2.ItemCode as 'FG Item Code',
    T3.ItemName as 'FG Item Name',
    T2.PlannedQty as 'FG Planned Qty',
    T2.U_OD as 'OD',
    T2.U_ID as 'ID',
    T2.U_OD/25.4 as 'Inches',
    (T2.U_OD-T2.U_ID)/2 as 'Width',
    0 as 'FG Pending Qty',
    0 as 'FG Receipt Qty',
    '' as 'Issue Item Code',
    '' as 'Issue Item Name',
    Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
    0 as 'Issue Item - Return Quantity',
    '' as 'Return Doc No',
    SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
    SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
    from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
    INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
    LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode not in (a.ItemCode)
    LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode INNER JOIN OIGN d on c.DocEntry = d.DocEntry
    WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
    GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID, T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2
    UNION ALL
    SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
    T2.DocNum AS 'WorkOrderNo',
    b.DocNum as 'Issue Doc No',
    ISNULL(d.DocNum,'') as 'Receipt Doc No',
    b.U_IssPSCName as 'SubContractor Name',
    T2.ItemCode as 'Item Code',
    T3.ItemName as 'Item Name',
    T2.PlannedQty as 'Planned Qty',
    T2.U_OD as 'OD',
    T2.U_ID as 'ID',
    T2.U_OD/25.4 as 'Inches',
    (T2.U_OD-T2.U_ID)/2 as 'Width',
    (Select (T2.PlannedQty - (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum))) as 'Pending Qty',
    (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum) as 'Receipt Qty',
    a.ItemCode as 'Issued Item Code',
    a.Dscription as 'Issued Item Name',
    Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
    (Select (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode))) as 'Issue Item - Return Quantity',
    (ISNULL((Select (Select a2.DocNum from OIGN a2 where a2.DocEntry = a1.DocEntry) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode)),'')) as 'Return Doc No',
    SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
    SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
    from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
    INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
    LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode in (a.ItemCode)
    LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode LEFT JOIN OIGN d on c.DocEntry = d.DocEntry 
    WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
    GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID,T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2,a.ItemCode,a.Dscription    order by T2.DocNum desc

    Hi,
    Try this:
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    Declare @SCCode nvarchar(30)
    select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
    select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
    --Rcpt from PRDN (Condition checked for Return component exclusion also)
    SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,
    T2.DocNum AS 'WorkOrderNo',
    b.DocNum as 'Issue Doc No',
    ISNULL(d.DocNum,'') as 'Receipt Doc No',
    b.U_IssPSCName as 'SubContractor Name',
    T2.ItemCode as 'FG Item Code',T3.ItemName as 'FG Item Name',T2.PlannedQty as 'FG Planned Qty',T2.U_OD as 'OD',T2.U_ID as 'ID',T2.U_OD/25.4 as 'Inches',(T2.U_OD-T2.U_ID)/2 as 'Width',case when ((T2.U_OD-T2.U_ID)/2) <30 then ((T2.U_OD-T2.U_ID)/2) *0.3 end, 0 as 'FG Pending Qty',0 as 'FG Receipt Qty','' as 'Issue Item Code','' as 'Issue Item Name',Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',0 as 'Issue Item - Return Quantity','' as 'Return Doc No',SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntryINNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCodeLEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode not in (a.ItemCode)LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode INNER JOIN OIGN d on c.DocEntry = d.DocEntryWHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,T2.PlannedQty,T2.U_OD,T2.U_ID, T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2UNION ALL SELECT T2.U_STKNO as 'PRN No', T2.PostDate as Date,T2.DocNum AS 'WorkOrderNo',
    b.DocNum as 'Issue Doc No',
    ISNULL(d.DocNum,'') as 'Receipt Doc No',
    b.U_IssPSCName as 'SubContractor Name',
    T2.ItemCode as 'Item Code',T3.ItemName as 'Item Name',T2.PlannedQty as 'Planned Qty',T2.U_OD as 'OD',T2.U_ID as 'ID',T2.U_OD/25.4 as 'Inches',(T2.U_OD-T2.U_ID)/2 as 'Width',case when ((T2.U_OD-T2.U_ID)/2) >=30 then ((T2.U_OD-T2.U_ID)/2) *0.37 end, (Select (T2.PlannedQty - (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum))) as 'Pending Qty',(Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum and a1.ItemCode in (b1.itemcode) where b1.DocNum = t2.DocNum) as 'Receipt Qty',
    a.ItemCode as 'Issued Item Code',
    a.Dscription as 'Issued Item Name',
    Sum(ISNULL(a.Quantity,0)) as 'Total Issue Quantity',
    (Select (Select ISNULL(sum(a1.Quantity),0) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry
    where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode))) as 'Issue Item - Return Quantity',
    (ISNULL((Select (Select a2.DocNum from OIGN a2 where a2.DocEntry = a1.DocEntry) from IGN1 a1 inner join OWOR b1 on a1.BaseRef = b1.DocNum inner join WOR1 b2 on b1.DocEntry = b2.DocEntry where b1.DocNum = t2.DocNum and a1.ItemCode in (b2.itemcode)),'')) as 'Return Doc No',
    SUM(ISNULL(a.U_IssPTotWeight,0)) as 'Total Issue Weight',
    SUM(ISNULL(c.U_Quantity,0)) as 'Total Receipt Weight'
    from OWOR T2 inner join WOR1 T4 on T2.DocEntry = T4.DocEntry
    INNER JOIN OITM T1 ON T1.ItemCode = T4.ItemCode inner join OITM T3 on T3.ItemCode = T2.ItemCode
    LEFT join IGE1 a on T2.DocNum = a.BaseRef Inner JOIN OIGE b on a.DocEntry = b.DocEntry and T4.ItemCode in (a.ItemCode)
    LEFT JOIN IGN1 c ON c.BaseRef = T2.DocNum and T2.ItemCode = c.ItemCode LEFT JOIN OIGN d on c.DocEntry = d.DocEntry
    WHERE b.Series in('101','20') and T2.PostDate >= @FromDate and T2.PostDate <= @ToDate and b.U_IssPSCName = '[%2]'
    GROUP BY T2.U_STKNO, T2.PostDate, T2.DocNum, b.DocNum, d.DocNum, b.U_IssPSCName,T2.ItemCode,T3.ItemName,
    T2.PlannedQty,T2.U_OD,
    T2.U_ID,T2.U_OD/25.4,(T2.U_OD-T2.U_ID)/2,a.ItemCode,a.Dscription  
    order by T2.DocNum desc
    Thanks & Regards,
    Nagarajan

  • How to implement this in Oracle Apps 11i

    Hello Friends
    I am working as a consultant for a manufacturing company.
    They have a format for charging Excise and Sales tax on their products (example below). I dont know how to implement this using oracle apps. Please help me ASAP.
    eg.
    Product A:
    MRP = Rs. 100
    Assessable Value (i.e. the value at which I have contract with the Government to pay Excise Duty) = 60% of MRP = Rs. 60 in this case.
    Excise Duty = 16% of AV =0.16*60 = Rs. 9.6
    Now, let’s suppose I am selling my product to a dealer at 30% discount.
    Therefore, Sale Price = 70% of MRP = Rs. 70
    Sales Tax = 4% of Sale Price = 0.04*70 = 2.8
    Therefore, total revenue from the deal = 70-9.6-2.8 = Rs. 57.6

    you can use Advance Pricing or creating discount or attiribute while calculating.
    this is not much complex, possible even with Advance Pricing too. Thanks
    Shiv

  • How to implement this code in labview?

    How do implement this pseudo code in labview? Please keep in mind "a" and "c" in the code below ARE VARIABLES
    for i =0 to i=maxvalue
           if i <= a 
               output = output2
           else if i > a AND i<=c
               output = output2
           else if i < c 
               output = output3
           else i = d
               output = output4
    I understance i can use a case structures and modify the label, but i do not know how to make the label dependent on a variable value. 
    Thanks 

    Try an array of boudaries and use threshold array. See this old example:
    Now just iterate over an array of values using a FOR loop.
    LabVIEW Champion . Do more with less code and in less time .

  • How to implement this functionality?

    hi,
    I want to use a thread to send all message centrally. The thread will check if the internal queue is empty. If the queue isn't empty, it sends the message, otherwise, it yields. The code snippet is as the following.
      public void run()
        logger.info("Sending thread started.");
        try{
          while (isConnected) {
            if (!bufferQueue.isEmpty() && !isReconnecting) {
              sendMsgInternal();
            } // bufferQueue.isEmpty()
            else {
              Thread.yield();
        catch (Exception e)
          logger.error("Fatal exception in sending thread", e);
          isConnected = false;
        finally
          sendThread = null;
      }This method works fine. But I found the CPU occupying rate is always 100%.
    Can somebody give me the better method to implement this logic with lower CPU occupying rate??
    Thanks in advance!
    Regards,
    Jason

    I think i have gotten the solution. It shouldn't use yield() method. It waste so much CPU time.
    I think the solution is using wait() and notify() in pair. The snippet code is as the following:
       public final synchronized void send(Object m) {
          if (m == null) {
             System.err.println("null message passed to send()");
             throw new NullPointerException();
          numMessages++;
          messages.addElement(m); // at end
          if (numMessages <= 0) notify();
       public final synchronized Object receive() {
          Object receivedMessage = null;
          numMessages--;
          if (numMessages < 0) {
             while (true) {     // we must be notified not interrupted
                try {
                   wait();
                   break;       // notify(), so get message
                catch (InterruptedException e) {
                   System.err.println
                      ("receive(): InterruptedException, wait again");
                   // race condition fix, see Semaphore.java
                   if (numMessages >= 0) break;
                   else continue;    // no message yet
          receivedMessage = messages.firstElement();
          messages.removeElementAt(0);
          return receivedMessage;
       public void run()
         logger.info("Sending thread started.");
         try{
           while (isConnected) {
               sendMsgInternal(receive());
         catch (Exception e)
           logger.error("Fatal exception in sending thread", e);
           isConnected = false;
         finally
         { // Set to null, avoid restarting the thread.
           sendThread = null;
       }For the details of this method, please refer to the following link:
    http://www.cs.drexel.edu/~shartley/ConcProgJava/messaging.html
    If there are some drawbacks, please let me know.
    Regards,
    Jason

  • How to implement this attribute ?

    Hi,
    I've this problem.
    In our application to control healthcare expense I've implemented a cube with 6 dimensions. (here for who knows Italian : http://www.oracle.com/global/it/customers/profiles/profile_77.html )
    The biggest dimension is the "patient" one, with 1.500.000 units at 5th level, grouped in geographic aggregates, until the entire city at highest level.
    Now customers wants to have the possibility to select patiens with chronic disease from these. There are about 500 kinds of chronic diseases.
    Every patient can have no one, one, or (and this is the problem) more then one of these chronic disease.
    How to try to implement this? as a new dimensions or as an attribute ?
    I've thought that best way is to introduce a new (chronic diseases) dimension, to have a way to select one or more of these diseases at all levels of patient dimension.
    I'm asking how to solve the problem that a single patien can also have more than one disease.
    Is there any way to implement this ?

    thanks to everyone for the answers
    I've some questions.
    to olapworld:
    have you any sample code to show me how to implement the dimensionalized valueset and the customizations needed ??
    to scott:
    I think I'm not understanding your suggestion:
    my target is to add the "ilnesses" selection to other ones. The most important cube of my applications analyze
    healthcare expenses from six dimensions. Customer wants analyze cube "adding" a way to select only "ilnesses" patients and elvaluate their expense.
    I'm in doubt becouse a patient can also have more then one ilness, so I can't simply add a "ilnesses" dimensions to the cube and mapping it to an "ilness_id" in the fact table.
    How can the two dimensioned cube to help me in this ?
    to Rafalm1:
    in any case, implementing Count(Distinct patient) would be useful for me, to have a way to count the number of patients who had a healthcae assistence. Can you suggest me how to implement this ?

  • How to Implement Hireachical Queries in ODI?

    Hello All,
    Please let me know how to implement Hierarchical Queries in ODI 11.1.1.6.?
    Pls provide any example if possible.
    Thanks
    Ravikiran

    there is no native way to use hierarchical queries.
    you will have to modify KM
    It depends on your exact needs.

  • How to implement mapping logic?

    Hi Experts,
    i have 5 idocs coming with structure as this.
    IDOC-1* SEGMENT-EKPKF*
        SEGMENT-EKSEG
        field-KOART=D
        field-SKHZG=H
        field-WRBTR=200.00
       SEGMENT-EKSEG
        field-KOART=D
        field-SKHZG=S
        field-WRBTR=230.00
    IDOC-2 SEGMENT-EKPKF
        SEGMENT-EKSEG
        field-KOART=D
        field-SKHZG=H
        field-WRBTR=50.00
       SEGMENT-EKSEG
        field-KOART=D
        field-SKHZG=S
        field-WRBTR=290.00
    now two fields of reciever structure should have value as
    FIELD-1
    add WRBTR for each idoc when KOART=D and SKHZG=H
    i.e result should be 250.00
    FIELD-2
    add WRBTR for each idoc when KOART=D and SKHZG=S
    i.e result should be 520.00
    can someone tell me how to implement this.....
    regards
    Akhil
    Edited by: Akhil Rastogi on Mar 13, 2008 11:03 AM

    EKPKF>RemoveContext>EKPKF
    EKSEG>RemoveContext>EKSEG
    SKHZG----
    Constant(H)>IFWITHOUTELSE ()> WRBTR-->FIELD1
                             SKHZG==H
    SKHZG----
    >
    Constant(S)>IFWITHOUTELSE ()> WRBTR-->FIELD2
                             SKHZG==S

  • How to implement this complex logic on rpd

    How to implement following sql logic on OBIEE 10g RPD...whole thing to be implemented as single column on presentation layer.
    to calculate numerator===
    select sum(flag) as ap_account_no,exp from                                                                                           
    (select a.invoice_id as invid,a.payment_no, max(a.payment_dt) as payment_dt,max(a.due_dt) as due_dt,b.expenditure_type as exp,                                                                                          
    case when max(a.due_dt)+ 3 > max(a.payment_dt)                                                                                           
    then 1                                                                                           
    else 0                                                                                           
    end As Flag                                                                                          
    from Supplier_inv_pymt_map a, po_invoice_map b                                                                                          
    where a.invoice_id= b.invoice_id and a.invoice_dt!=a.due_dt and a.usd_gross_AMOUNT >0 and a.PAYMENT_STATUS!='VOIDED' and to_char(a.payment_dt,'MON-YYYY')='JUN-2011'                                                                                          
    group by a.invoice_id, a.payment_no,b.expenditure_type) GROUP BY exp                                                                                          
    to calculate denominator===
    select count(invid),exp from                                                                                      
    (select a.invoice_id as invid,a.payment_no, max(a.payment_dt) as payment_dt,max(a.due_dt) as due_dt, b.expenditure_type as exp                                                                                     
    from Supplier_inv_pymt_map a, po_invoice_map b                                                                                     
    where a.invoice_id= b.invoice_id and a.invoice_dt!=a.due_dt and a.usd_gross_AMOUNT >0 and a.PAYMENT_STATUS!='VOIDED' and to_char(a.payment_dt,'MON-YYYY')='JUN-2011'                                                                                     
    group by a.invoice_id, a.payment_no,b.expenditure_type) GROUP BY exp                                                                                     
    tables n column used in sql r available on physical layer....
    can anyone help

    Hi
    if you don't want to aggregate try to define a user function
    analytic_sum($(value))
    implémented by
    sum($(value))
    after that
    replace your
    sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
    by
    analytic_sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)

  • How do i implement this logic in a Single SQL?

    Hi Friends!
    I’m having some problem. Hope you can share your thoughts with me.
    Let’s come to the problem
    I’m having following recordset
    S_id     t_nbr     d_id     a_dtm               b_dtm               c_dtm               create_tmstmp                    ind_f
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:48:00     22-Nov-2007 13:43:00     23-Nov-2007 01.01.14.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:58:00     22-Nov-2007 13:43:00     23-Nov-2007 01.03.00.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:30:00     22-Nov-2007 14:44:00     23-Nov-2007 01.04.05.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.07.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.22.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.05.46.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.06.01.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.07.13.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:40:00     22-Nov-2007 13:43:00     23-Nov-2007 01.08.26.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:51:00     22-Nov-2007 13:43:00     23-Nov-2007 01.09.27.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:01:00     22-Nov-2007 14:43:00     23-Nov-2007 01.10.19.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.11.46.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.12.01.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.20.13.000000000 AM     LNow,
    We have to consider a record as duplicate if the combination of a_dtm||b_dtm||c_dtm are same.
    First, we have to select all the unique record. That will be part of our output -
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:48:00     22-Nov-2007 13:43:00     23-Nov-2007 01.01.14.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:58:00     22-Nov-2007 13:43:00     23-Nov-2007 01.03.00.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:30:00     22-Nov-2007 14:44:00     23-Nov-2007 01.04.05.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:40:00     22-Nov-2007 13:43:00     23-Nov-2007 01.08.26.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:51:00     22-Nov-2007 13:43:00     23-Nov-2007 01.09.27.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:01:00     22-Nov-2007 14:43:00     23-Nov-2007 01.10.19.000000000 AM     LSecond, we have to deals with the duplicate record.
    That means the duplicate record set will be as follows -
    set 1:
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.07.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.22.000000000 AM     U
    set 2:
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.05.46.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.06.01.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.07.13.000000000 AM     Lset 3:
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.11.46.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.12.01.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.20.13.000000000 AM     LSelection of 1 record from each duplicate set:
    In case of set 1:
    Since there is no 'L' in ind_f column, we will pick the first record from it. So the selected record will be -
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.07.000000000 AM     UIn case of set 2:
    Since there is 'L' in ind_f column for the first entry from that duplicate set, we will select the first record as -
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.05.46.000000000 AM     LIn case of set 3:
    Since there is 'L' in ind_f column, we will start searching from the first record of that duplicate set. We got 'L' in the second record from that set.
    Hence we will select the following record -
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.12.01.000000000 AM     LSo, our final output will be the combination of distinct record and one record that is selected from our duplicate set. Hence the final output will be -
    S_id     t_nbr     d_id     a_dtm               b_dtm               c_dtm               create_tmstmp                    ind_f
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:48:00     22-Nov-2007 13:43:00     23-Nov-2007 01.01.14.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:58:00     22-Nov-2007 13:43:00     23-Nov-2007 01.03.00.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:30:00     22-Nov-2007 14:44:00     23-Nov-2007 01.04.05.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 14:31:00     22-Nov-2007 14:45:00     23-Nov-2007 01.04.07.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:29:00     22-Nov-2007 13:43:00     23-Nov-2007 01.05.46.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:40:00     22-Nov-2007 13:43:00     23-Nov-2007 01.08.26.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 13:51:00     22-Nov-2007 13:43:00     23-Nov-2007 01.09.27.000000000 AM     U
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:01:00     22-Nov-2007 14:43:00     23-Nov-2007 01.10.19.000000000 AM     L
    306     1107     YYZ     22-Nov-2007 12:32:00     22-Nov-2007 15:29:00     22-Nov-2007 15:43:00     23-Nov-2007 01.12.01.000000000 AM     LI've already identify the duplicate records in a single SQL query. But, unable to implement this selection approach of single record from the duplicate set.
    How do i achive this in a single SQL?
    By the way,
    I'm using Oracle 9i.
    Thanks for your efforts in advance.
    Regards.
    Satyaki De.
    Oops! You are right. I've made the change.
    N.B.: The duplicate sets will form based on the create_tmstmp field

    Hi, Satyaki.
    Your query should be very simple:
    SQL> with t as
      2  (select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:48:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.01.14.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
      3   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:58:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.03.00.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
      4   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 14:30:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:44:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.04.05.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
      5   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 14:31:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:45:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.04.07.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
      6   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 14:31:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:45:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.04.22.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
      7   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.05.46.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
      8   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.06.01.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
      9   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.07.13.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
    10   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:40:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.08.26.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
    11   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 13:51:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.09.27.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
    12   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 15:01:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.10.19.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
    13   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.11.46.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'U'     ind_f from dual union all
    14   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.12.01.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual union all
    15   select 306 S_id, 1107 t_nbr, 'YYZ'     d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm,     to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss')     c_dtm,     to_timestamp('23-Nov-2007 01.20.13.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM')     create_tmstmp, 'L'     ind_f from dual)
    16   --
    17   select *
    18     from (select t.*,
    19                  row_number() over(partition by s_id, t_nbr, d_id, a_dtm, b_dtm, c_dtm order by nullif(ind_f, 'U') nulls last, create_tmstmp) rn
    20             from t)
    21    where rn = 1
    22  /
          S_ID      T_NBR D_ID A_DTM       B_DTM       C_DTM       CREATE_TMSTMP                                     IND_F         RN
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.05.46.000000000 AM                   L              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.08.26.000000000 AM                   L              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.01.14.000000000 AM                   L              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.09.27.000000000 AM                   U              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.03.00.000000000 AM                   L              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.04.05.000000000 AM                   U              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.04.07.000000000 AM                   U              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.10.19.000000000 AM                   L              1
           306       1107 YYZ  22.11.2007  22.11.2007  22.11.2007  23-NOV-07 01.12.01.000000000 AM                   L              1
    9 rows selected
    SQL> \PS BTW you're not a newbie in the forum, please, post WITH clause or CREATE/INSERT statement for your data next time.

  • How to implement this calendar function in ABAP code

    Hi everyone,
    Our requirement is : Give a date (e.g. YYYY.MM.DD, 1983.12.26), then we need to know which weekday it is. Is there a existing FM for this fuction? or how to implement it in ABAP?
    Thanks a lot for any hint
    Best regards
    Deyang

    Hi Deyang Liu,
        Could you please check these the below links they would give you some idea ....[SAP Calendar Control|http://help.sap.com/printdocu/core/print46b/en/data/en/pdf/BCCICALENDAR/SAP_KALENDER.pdf]
    [Calendar functions |http://help.sap.com/saphelp_nw04/Helpdata/EN/2a/fa00f6493111d182b70000e829fbfe/content.htm]
    [SAP Functions|http://abap4.tripod.com/SAP_Functions.html]
    [Determine calendar |http://help.sap.com/saphelp_nw04/helpdata/en/2a/fa00e9493111d182b70000e829fbfe/content.htm]
    Regards,
    S.Manu

  • How to implement this in Smartforms

    Hello,
    I have been given this information for what is wanted in a proforma invoice:
    Print a field for bankcode. Field name = tempBANKL.
    Logic:
    Select BANKS BANKL into tempBANKS tempBANKL from T012
    where BUKRS = ls_bil_invoice-HD_ORG-COMP_CODE and HBKID = tempHBKID.
    What do I need of nodes in my window in order to implement this ?
    Thanks in advance.

    Hi
    In the program line node just before the Text node where you need to print the Bank  code, pass ls_bil_invoice-HD_ORG-COMP_CODE  and tempHBKID as Inputs/Import and tempBANKS and tempBANKL as ouput/Export
    In this program line node, you can have your select statement. And, the text node below, will have &tempBANKL& as content.
    Regards
    Raj

Maybe you are looking for