Question On YTD Total Sales Query

Hello,
We use this query below to see YTD sales for each of our BP Customers:
SELECT T0.CardCode 'Acct #', T0.CardName Company, T0.Address
' Address', T0.City ' City', T0.State1 State, T0.ZipCode
'Billing Zip', T0.Phone1 Phone, T0.Balance ' Balance',
T1.SlpName 'Sales Rep',
T2.PymntGroup Terms, T3.GroupName 'Group', ((SELECT ISNULL(SUM(INV1.LINETOTAL),0)
FROM INV1 INNER JOIN OINV ON INV1.DocEntry = OINV.DocEntry
WHERE OINV.CardCode = T0.CardCode AND Year(INV1.DocDate) = Year(GetDate()))-(SELECT ISNULL(SUM(RIN1.LINETOTAL),0)
FROM RIN1 INNER JOIN ORIN ON RIN1.DocEntry = ORIN.DocEntry
WHERE ORIN.CardCode = T0.CardCode AND Year(RIN1.DocDate) = Year(GetDate()))) [YTD Sales]
FROM OCRD T0
LEFT JOIN OSLP T1 ON T1.SlpCode = T0.SlpCode
LEFT JOIN OCTG T2 ON T2.GroupNum = T0.GroupNum
LEFT JOIN OCRG T3 ON T3.GroupCode = T0.GroupCode
WHERE T0.CardType = 'C'
We use this query below to see daily Invoice and Credit Memo postings for a selected period:
SELECT 'INVOICE' as "Doc Type", T0.DOCNUM as "Doc Number", T0.CARDCODE as "Customer Code", T0.CARDNAME as "Customer Name", T0.DOCDATE as "Posting Date", T0.NUMATCARD as "Customer Ref #", T0.DocDueDate, T0.DocTotal
FROM [dbo].[OINV] T0 WHERE T0.DOCDATE BETWEEN '[%0]' And '[%1]'
UNION ALL
SELECT 'CREDIT MEMO', T0.DOCNUM,T0.CARDCODE, T0.CARDNAME, T0.DOCDATE, T0.NUMATCARD, T0.DocDueDate, -1*T0.DocTotal
FROM [dbo].[ORIN] T0 WHERE T0.DOCDATE BETWEEN '[%0]' And '[%1]'
My question is -- shouldn't the sum of the YTD column in the 1st Query be the same as the sum of the Doc Total column in the 2nd Query (given that all dates are selected in the 2nd Query)? 
This doesn't appear to be the case and I was wondering why?
Thanks,
Mike

Mike,
The DocTotal may contain Freight and Handling expenses, While the first query only taken the SUM of the line total of the Items.
Thats why they may be different.
Suda

Similar Messages

  • How to Apply YTM and MTD filter to the Query Calculating "Total Sales" Amt

    Hi,
    I got the requirement to calculate "Total Sales" amount in following format,
    1. Calculate Total Sales YTM per Country
    2. Calculate Total Sales MTD per Country
    I am done with Queries to get Country wise Total Sales amount but stuck at the point, how to apply YTM (Year to Month) and MTD (Month to Date) filter. Can anyone have idea about how to apply YTM and MTD filter to query??
    Regards,
    Priyanka

    Hi,
    I got the requirement to calculate "Total Sales" amount in following format,
    1. Calculate Total Sales YTM per Country
    2. Calculate Total Sales MTD per Country
    I am done with Queries to get Country wise Total Sales amount but stuck at the point, how to apply YTM (Year to Month) and MTD (Month to Date) filter. Can anyone have idea about how to apply YTM and MTD filter to query??
    Regards,
    Priyanka

  • Regarding Customer Total Sales table

    Hi All SAP Experts
    I like to know which table will provide me total of each customers for year. an Actual sales for per customer. I know table VBAK with filed Net value. My question is that figure is right figure for each customer. I am looking for total sales. Report requirement is total sales it will not show line itemwise. Just total sales per customer.
    Thank you

    Welcome to the forum.  As a new member, I would like to inform you that there are certain rules and regulations applicable to this forum which you can find to your right screen where it has also been indicated that posting basic / repeated query is not allowed. Please search in this forum or Google it with the same text, so that you will find many threads discussed on the same topic.  Take the inputs from there and update still if you are not able to resolve.  Meanwhile, this thread would be locked.
    G. Lakshmipathi

  • Custom YTD/TOTALS

    Hi all,
    I would like to customize the YTD & TOTAL inner calculations depending on the account type.
    For example, if I want the TOTAL or YTD sales I want that BPC calculates it as a sum of the different periods (this is what I understand is standard calculation).
    In the other side, if I want the Customer end of period TOTALS or YTD, I don't want BPC to accumulate from Jan to Dec (it should be great for my company results, but it's not the reality), I'd like to use a custom calculation that takes previous period data (for example Dec-08 if I am asking for the 2008 totals or DEC YTD).
    Can I customize it by using a business rule or is it better to create a mdx logic? I have allready created a mdx Logic, but it takes a long time to calculate the data.
    I'd apreciate if someone can help me on this issue or if someone has another possible solution.
    Thanks in advance for all your help.

    I am not sure if I completely follow your question, but I have a suggestion.  If you are using BPC 7M SP3 or higher, you may have more than 1 TIME HIERARCHY.  So it would be possible to have a Calendar view and a seperate view based on a different set months to quarters, years etc.
    If that doesn't solve your question, then I would look into building a custom MEASURE that would be executed on all sets of data for certain applications.  There is a How To Guide that has example of building a custom Measure for reporting purposes on SDN.
    Hope this helps.

  • Need help getting YTD total

    I've got a period to date report with following columns:
    week1 tots, week2 tots, week3 tots, week4 tots, week5 tot, period-to-date tots, year-to-date tots
    I have a SELECT statement which totals data for the entire year and separates current period totals
    by grouping on the week_nbr . Any date between beginning of year and the end of the previous period will be week 0
    The Select statement retursn 6 rows: 1 for each week in period and one with week_nbr = 0 which represents the totals from the beginning of year
    to the end of the previous period.
    the select statement returns the data correctly . I need help getting the YTD total for (weeks 1 - 5) + (totals for week 0) for each column.
    This means that I will have a 7th record containing the YTD totals. ( I am not concerned with the PTD totals)
    I tried sum by partition but complex decode statement gave me problems.
      CREATE TABLE PERIOD_DATA
       (     "HOT_DOG_STAND_ID" NUMBER NOT NULL ENABLE,
         "WEEK_DATE" DATE,
         "NET_SALES2" NUMBER,
         "BUNS24434" NUMBER,
         "PICKELS_AW38" NUMBER,
         "MUSTARD_TB56" NUMBER,
         "CHICKENHEADS33" NUMBER,
         "PIECES_SOLD34" NUMBER,
         "SCRAPS35" NUMBER,
         "PIECES_UNACCOUNTED" NUMBER
    REM INSERTING into PERIOD_DATA
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-DEC-08','DD-MON-RR HH.MI.SSXFF AM'),14301.39,13951.26,3431.13,0,3680,2484,378,818);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('05-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14651.37,14651.37,3249.55,0,3200,2419,505,276);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('12-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),14169.89,14169.89,2463.53,0,3136,2080,474,582);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('19-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15864.46,15864.46,3245.49,0,3472,2764,475,233);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('26-JAN-09','DD-MON-RR HH.MI.SSXFF AM'),15961.2,15916.23,3395.51,0,3648,2838,392,418);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),19066.4,19066.4,4165.07,0,4336,3682,333,321);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18415.74,18415.74,4024.74,0,4032,3365,482,185);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18014,17849,3486.33,0,3840,3238,374,228);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-FEB-09','DD-MON-RR HH.MI.SSXFF AM'),18671.09,18626.12,3729.42,0,3888,2970,353,565);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('02-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17636,17636,3815,0,3424,2840,490,94);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('09-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),17235.52,17145.58,3897.42,0,3504,2928,421,155);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('16-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),15989.27,15989.27,3372.95,0,3728,3051,369,308);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('23-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),19067.69,18960.41,4152.6,0,4048,3293,442,313);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('30-MAR-09','DD-MON-RR HH.MI.SSXFF AM'),18717.99,18717.99,3923.69,0,4408,3219,593,596);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-APR-09','DD-MON-RR HH.MI.SSXFF AM'),17335.16,17335.16,3769.08,0,3928,2997,514,417);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-APR-09','DD-MON-RR HH.MI.SSXFF AM'),18967.39,18967.39,4157.76,0,4144,2991,527,626);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-APR-09','DD-MON-RR HH.MI.SSXFF AM'),23090.88,23090.88,4427.96,0,5544,4493,560,491);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-APR-09','DD-MON-RR HH.MI.SSXFF AM'),24197.98,24132.99,4248.66,0,6680,5190,606,884);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('04-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),20202.21,20137.22,3714.68,0,7052,6170,422,460);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('11-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18514.48,18514.48,3266.06,0,5508,4178,571,759);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('18-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),18678.68,18678.68,3814.07,0,5824,4345,633,846);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('25-MAY-09','DD-MON-RR HH.MI.SSXFF AM'),17937.18,17937.18,3051.52,0,4844,4986,529,-671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('01-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17445.75,17445.75,3079.91,0,5028,4810,656,-438);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('08-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17327.88,17327.88,3263.29,0,6112,4674,672,766);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('15-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17241.72,16937.33,3328.27,0,5792,4490,567,735);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('22-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),16625.83,16625.83,3485.18,0,5408,4319,761,328);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('29-JUN-09','DD-MON-RR HH.MI.SSXFF AM'),17002.84,17002.84,3091.09,0,5664,4369,544,751);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('06-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16339.19,16274.2,3075.3,0,4784,3440,697,647);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('13-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17165.12,16885.14,3458.03,0,4320,3296,640,384);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('20-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),17029.77,16899.79,3198.91,0,4448,3449,645,354);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('27-JUL-09','DD-MON-RR HH.MI.SSXFF AM'),16596.89,16596.89,3015.54,0,4624,3288,665,671);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('03-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),16468.58,16468.58,2981.35,0,2224,3495,564,-1835);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('10-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18625.48,18550.5,3524.44,0,4856,3482,578,796);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('17-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),24538.54,24323.55,5580.71,0,5260,3771,608,881);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('24-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),18081.37,18081.37,3533.45,0,5980,3080,553,2347);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('31-AUG-09','DD-MON-RR HH.MI.SSXFF AM'),17183.25,17183.25,3487.12,0,2544,3262,615,-1333);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('07-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),17688.41,17575.29,3424.17,0,4800,3480,591,729);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('14-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),18211.29,18211.29,3806.32,0,3968,3104,527,337);
    Insert into PERIOD_DATA (HOT_DOG_STAND_ID,WEEK_DATE,NET_SALES2,BUNS24434,PICKELS_AW38,MUSTARD_TB56,CHICKENHEADS33,PIECES_SOLD34,SCRAPS35,PIECES_UNACCOUNTED) values (141,to_timestamp('21-SEP-09','DD-MON-RR HH.MI.SSXFF AM'),16809.21,16744.22,3014.61,0,4128,3124,710,294);
    SELECT HOT_DOG_STAND_ID
    , DECODE(TRUNC(week_date , 'iw') ,
             to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
             to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0) AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY hot_dog_stand_id
    , DECODE(TRUNC(week_date , 'iw') ,
          to_date('24-AUG-09' , 'dd-mon-rr') , 1 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 ,
          to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 ,
          0)
    ORDER BY DECODE(TRUNC(week_date , 'iw') , to_date('24-AUG-09' , 'dd-mon-rr') , 1 , to_date('24-AUG-09' , 'dd-mon-rr') + 7 , 2 , to_date('24-AUG-09' , 'dd-mon-rr') + 14 , 3 , to_date('24-AUG-09' , 'dd-mon-rr') + 21 , 4 , to_date('24-AUG-09' , 'dd-mon-rr') + 28 , 5 , 0);The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                  You can get these dame results by running endpot-to-endpoint query:
    SELECT  HOT_DOG_STAND_ID
         , max(7) as week_nbr
         ,sum(NET_SALES2)      net_sales2
          ,sum(BUNS24434 )        BUNS24434
          ,sum(PICKELS_AW38)      PICKELS_AW38
          ,sum(MUSTARD_TB56)     MUSTARD_TB56
          ,sum(CHICKENHEADS33)   CHICKENHEADS33
          ,sum(PIECES_SOLD34)    PIECES_SOLD34
          ,sum(SCRAPS35)         SCRAPS35
          ,sum(PIECES_UNACCOUNTED)   PIECES_UNACCOUNTED
        ---===== Copied code from outer query
              --==  net_sales / chickenusage 
                      ,   CASE
                             WHEN NVL( sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                             ELSE ROUND(sum(net_sales2)/   ( sum(ChickenHeads33) / 8    ) , 2)
                          END as Head_average
                        --=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100
                        ,   CASE
                                  WHEN NVL(sum(ChickenHeads33) / 8    ,0)  = 0 then 0
                                  ELSE   ROUND((((sum(ChickenHeads33) / 8 )  - ( sum(scraps35) / 8 ) - (sum(pieces_unaccounted) / 8 )) / (sum(ChickenHeads33) / 8 )) * 100, 2)
                          END as efficiency  
    from period_data
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' ,'DD-MON-YY'), 'IY') AND TO_DATE( '27-sep-09' ,'DD-MON-YY')
    group by hot_dog_stand_id;Thanks In Advance

    Hi,
    Welcome to the forum!
    Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful. You could teach something to some people who have been using this forum for years (except that nobody can teach them).
    user12335325 wrote:
    The expected results will be:
    HOT_DOG_STAND_ID       WEEK_NBR               NET_SALES2             BUNS24434              PICKELS_AW38           MUSTARD_TB56           CHICKENHEADS33         PIECES_SOLD34          SCRAPS35               PIECES_UNACCOUNTED     HEAD_AVERAGE           EFFICIENCY            
    141                    7                      697067.09              694887.4               139149.91              0                      175808                 139454                 21036                  15318                  31.72                  79.32                 
    Do you mean the expected results will include the row above, and that the results will be this row along with the 6 rows you're already getting? (If you wanted just that one row, I suppose you would just run your second query.)
    That sound like a job for ROLLUP.
    VARIABLE   start_date     VARCHAR2 (11);
    EXEC         :start_date  := '24-AUG-2009';
         SELECT  HOT_DOG_STAND_ID
         ,      NVL (CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                      END
                 , 7
                 )          AS week_nbr
    , SUM(NET_SALES2)                                                                                                                                                                                                                                                     AS net_sales2
    , SUM(BUNS24434 ) BUNS24434
    , SUM(PICKELS_AW38) PICKELS_AW38
    , SUM(MUSTARD_TB56) MUSTARD_TB56
    , SUM(CHICKENHEADS33) CHICKENHEADS33
    , SUM(PIECES_SOLD34) PIECES_SOLD34
    , SUM(SCRAPS35) SCRAPS35
    , SUM(PIECES_UNACCOUNTED) * - 1 PIECES_UNACCOUNTED
       /*--== Head average  net_sales / chickenusage*/
    , CASE
          WHEN NVL( SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND(SUM(net_sales2) / ( SUM(ChickenHeads33) / 8 ) , 2)
       END AS Head_average
       /*--=== Efficiency =   (ChickenUsage  - scrappedDiv8 - unaccountedDiv8) / ChickenUsage)  * 100*/
    , CASE
          WHEN NVL(SUM(ChickenHeads33) / 8 , 0) = 0 THEN 0
          ELSE ROUND((((SUM(ChickenHeads33) / 8 ) - ( SUM(scraps35) / 8 ) - (SUM(pieces_unaccounted) / 8 )) / (SUM(ChickenHeads33) / 8 )) * 100 , 2)
       END AS efficiency
    FROM period_data per
    WHERE week_DATE BETWEEN TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IY') AND TRUNC(TO_DATE( '24-AUG-09' , 'DD-MON-YY') , 'IW') + 6 + 7 * 4
    GROUP BY  hot_dog_stand_id
    ,           ROLLUP (
                 CASE
                   WHEN  week_date >= TO_DATE( :start_date, 'DD-MON-YYYY')
                   AND   week_date <  TO_DATE( :start_date, 'DD-MON-YYYY') + 35
                   THEN  1 + FLOOR ( (week_date - TO_DATE( :start_date, 'DD-MON-YYYY'))
                                             / 7
                   ELSE  0
                 END          -- week_nbr
    ORDER BY  week_nbr
    ;Notice I simplified the computation of week_nbr.
    Some other people have asked questions about hot dog stands recently.
    I'm curious; is this from a course? If so, where? What is the textbook (if any)?
    Thanks.

  • How to get the max total sale by date on every store

    I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date

    Hi,
    Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
    Hjava wrote:
    I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
    Do you mean you want to see the store_id that had the maximum total sale?
    In general, this can be done with a Top-N Query, using an analytic function such as RANK.  For an example, see http://forums.oracle.com/forums/thread.jspa?messageID=3739610
    If you only want the date, the maximum total from that date, and 1 column from the same row with the maximum (e.g. store_id), then you might be able to use the aggregate LAST function instead.
    What results do you want in case of a tie?  (That is, if 2 or mote store_ids have the same total sale on a given date, and no other store_id has a higher total.)

  • Report on open sales order ,total sales

    Hello Gurus
    I am developing a report line item wise of sales order in which i need to get
    Suppose a sales order is created on 01.12.2009 for 1000 quantity
    billed quantity in december 600
    billed quantity in january     200
    1) total sales done against this SO line item wise.
    2) sales in this month againt this SO
    3)open order qty as 01.01.2010
    4)last day sales i.e from 01.01.2010 to 20.01.2010 the date of last sales against this SO
    so my output should be
    total sales = 800
    sales in this month =200
    open order qty as on 01.01.2010= 400
    please tell me the logic
    regards
    sphoorthi
    Moderator message - Please do not post your requirements and ask the forum to do your work for you - post locked
    Edited by: Rob Burbank on Jan 20, 2010 10:47 AM

    Hi,
    I gather from your thread that the question is not to build a report on a MP yes/no but more on which MP.
    Depending on the reporting needs and on how well you are able to combine the 2 cubes in the new MP I would say go for the latter option so you have more control on this one MP (for example if you need to add something that is already available in cubes).
    However, when (future!) reporting needs could mean that characteristics need to be added to the report(s) and filtered on that are not in both cubes you will have major problems getting the data properly from new MP and you would be better off using the individuals MP's and combine the data in a workbook or in a web template giving more flexibility.
    So you need to really analyze the requirements and decide on the way forward. Keep in mind possible future requirements because for now it could seem these few fields could be enough but new requirements could directly give a problem.
    Hope this helps
    C.

  • How to see customers total sales orders value

    Dear all,
    How can I create a query to see all customers total sales orders value.
    I have tried MC+E transaction, it is not giving accurate values when compare for a customer with VA05N report.
    moreover it doesn't have filter option.
    Please help me to resolve the issue. Your suggestion will be highly appreciated.
    Best regards,
    Raghu ram

    Hi,
    Try S_ALR_87012171  and S_ALR_87012186.   or
    S_ALR_87012160, select customer lite items only, enter customer number.
    Click on dynamic selection (Shift+F4). enter RV in document type field and press execute.
    Regards,
    Chandra

  • Trying to find the difference between two sub-totals (sales - credits)

    Hi Everyone,
    I have the following code which essentially lists the total sales for an items on the first row, and the total credits for the same item on the second row.
    SELECT T0.ItemCode, SUM(T0.LineTotal) as 'Total Sales'
    FROM INV1 T0
    WHERE T0.ItemCode = 'ACR2401010'
    GROUP BY T0.ItemCode
    UNION ALL
    SELECT T1.ItemCode, SUM(T1.LineTotal) as 'Total Sales'
    FROM RIN1 T1
    WHERE T1.ItemCode = 'ACR2401010'
    GROUP BY T1.ItemCode
    The results of the query are shown below (with some alterations for confidentiality).
    What I would like to do is write a code block that subtracts the total credits from the total sales, leaving me with only one row of data for the ItemCode.
    If anybody can help with writing the code to achieve this it will be greatly appreciated.
    Kind Regards,
    Davo

    Hi, Please take a look and tweak accordingly. You may pay attention to nulls and manipulate accordingly. Best of luck!
    --Option 1
    SELECT t2.ItemCode,( SUM(T2.TotalSales)-SUM(TotalCredits)) AS 'Total'
    FROM
    SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales',SUM(0) as 'TotalCredits'
    FROM INV1 as T0
    WHERE T0.ItemCode = 'ACR2401010'
    GROUP BY T0.ItemCode
    UNION ALL
    SELECT T1.ItemCode, SUM(0) as 'TotalSales', SUM(T1.LineTotal) as 'TotalCredits',
    FROM RIN1 as T1
    WHERE T1.ItemCode = 'ACR2401010'
    GROUP BY T1.ItemCode
    ) AS t2
    GROUP BY t2.ItemCode
    --Option 2
    SELECT t2.ItemCode, ( SUM(T2.TotalSales)-SUM(TotalCredits)) AS 'Total'
    FROM
    SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales',SUM(0) as 'TotalCredits'
    FROM INV1 as T0
    --WHERE T0.ItemCode = 'ACR2401010'
    GROUP BY T0.ItemCode
    UNION ALL
    SELECT T1.ItemCode, SUM(0) as 'TotalSales', SUM(T1.LineTotal) as 'TotalCredits',
    FROM RIN1 as T1
    --WHERE T1.ItemCode = 'ACR2401010'
    GROUP BY T1.ItemCode
    ) AS t2
    WHERE t2.ItemCode = 'ACR2401010'
    GROUP BY t2.ItemCode
    --Option 3
    SELECT t2.ItemCode, ( SUM(T2.TotalSales)-SUM(TotalCredits) ) AS 'Total'
    FROM
    SELECT T0.ItemCode, T0.LineTotal as 'TotalSales', 0 as 'TotalCredits'
    FROM INV1 as T0
    UNION ALL
    SELECT T1.ItemCode, 0 as 'TotalSales', T1.LineTotal as 'TotalCredits',
    FROM RIN1 as T1
    ) AS t2
    WHERE t2.ItemCode = 'ACR2401010'
    GROUP BY t2.ItemCode
    --Assuming credit part is optional..also assuming each table should return only one row else results would inflate...option 4
    SELECT t0.ItemCode, ( SUM(T0.TotalSales)-SUM(T1.TotalSales)) AS 'Total'
    FROM
    INV1 as t0
    left outer join
    RIN1 as t1
    ON t0.ItemCode = t1.ItemCode
    WHERE t0.ItemCode = 'ACR2401010'
    GROUP BY t0.ItemCode
    --option 4 with grouping to ensure single row from each table
    SELECT t0.ItemCode, ( isnull(T0.TotalSales,0)-isnull(T1.TotalSales,0)) AS 'Total'
    FROM
    SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales'
    FROM INV1 as T0
    --WHERE T0.ItemCode = 'ACR2401010'
    GROUP BY T0.ItemCode
    )as t0
    LEFT OUTER JOIN
    ( SELECT T1.ItemCode, SUM(T1.LineTotal) as 'TotalCredits',
    FROM RIN1 as T1
    --WHERE T1.ItemCode = 'ACR2401010'
    GROUP BY T1.ItemCode
    ) as t1
    ON t0.ItemCode = t1.ItemCode
    WHERE t0.ItemCode = 'ACR2401010'
    --Option 5 with grouping to ensure single row from each table.
    --Also assuming that sales or credits can be optional
    SELECT
    ISNULL(t0.ItemCode,t0.ItemCode) AS ItemCode,
    ( isnull(T0.TotalSales,0)-isnull(T1.TotalSales,0)) AS 'Total'
    FROM
    SELECT T0.ItemCode, SUM(T0.LineTotal) as 'TotalSales'
    FROM INV1 as T0
    --WHERE T0.ItemCode = 'ACR2401010'
    GROUP BY T0.ItemCode
    )as t0
    FULL OUTER JOIN
    ( SELECT T1.ItemCode, SUM(T1.LineTotal) as 'TotalCredits',
    FROM RIN1 as T1
    --WHERE T1.ItemCode = 'ACR2401010'
    GROUP BY T1.ItemCode
    ) as t1
    ON t0.ItemCode = t1.ItemCode
    WHERE (t0.ItemCode = 'ACR2401010' OR t1.ItemCode = 'ACR2401010')

  • Reg: Total sales of each month of customer

    Dear All,
    I have the below two tables
    Customers (customer_id, custer_name,customer_address)
    Sales (sales_id, sales_cust_id, sales_order_date, sales_amount)
    I need to write the SQL query to display the total sales made by each customer, each month with grand total of all months of current year
    can anyone help regarding this..
    Sample
    customer_id
    customer_name
    month
    total_sales
    12
    aaa
    Jan
    15242
    12
    aaa
    Feb
    17889
    (Total)
    33131
    13
    bbb
    Feb
    1487
    13
    bbb
    Jun
    19987
    (Total)
    21474

    Hi,
    You can use GROUP BY GROUPING SETS to get sub-totals in SQL:
    SELECT    sales_cust
    ,         NVL ( TO_CHAR ( TRUNC (sales_order_date, 'MONTH')
                            , 'Month YYYY'
                  , '   All months'
                  )    AS month
    ,         SUM (sales_amount)  AS total_sales
    FROM      t
    GROUP BY  GROUPING SETS ( (sales_cust, TRUNC (sales_order_date, 'MONTH'))
                            , (sales_cust)
    ORDER BY  sales_cust
    ,         TRUNC (sales_order_date, 'MONTH')
    Output from the sample data Ramin posted:
    SALES_CUST MONTH           TOTAL_SALES
            12 May       2013          120
            12 June      2013           15
            12 July      2013          110
            12 September 2013          750
            12    All months           995
            13 May       2013           70
            13 July      2013          205
            13    All months           275

  • Can a JOIN be used instead of a UNION to obtain the Total Sales from B1?

    Hi Everyone,
    I am in the midst of writing a report which shows the 'Total Sales', 'Gross Profit', and 'Gross Profit %' by Sales Person. Traditionally I have used a UNION between two result sets to achieve this task. However I am wondering it if is possible to achieve the same outcome with a JOIN as shown below?
    SELECT
        T0.SlpCode
        , T0.SalesPerson
        , T0.Branch
        , (T0.TotalSales - T1.TotalSales) AS 'Total Sales'
        , ((T0.TotalSales - T1.TotalSales) - (T0.StockValue + T1.StockValue)) AS 'Gross Profit'
        , CAST(((T0.TotalSales - T1.TotalSales) - (T0.StockValue + T1.StockValue)) / NULLIF((T0.StockValue + T1.StockValue), 0) * 100 AS decimal(15,2)) AS 'Gross Profit %'
        FROM
            /*** SAP - Invoices by Sales Person ***/
            SELECT
            T1.SlpCode
            , T2.SlpName AS 'SalesPerson'
            , T2.U_INE_Branch AS 'Branch'
            , CAST(SUM(T0.LineTotal) AS decimal(15,2)) AS 'TotalSales'
            , CAST(SUM(T0.StockValue) AS decimal(15,2)) AS 'StockValue'
            FROM AU.dbo.INV1 T0
            INNER JOIN AU.dbo.OINV T1 ON T1.DocEntry = T0.DocEntry
            LEFT JOIN AU.dbo.OSLP T2 ON T2.SlpCode = T1.SlpCode
            WHERE T1.DocDate >= '2014-08-01' AND T1.DocDate <= '2014-09-01'
            GROUP BY T1.SlpCode, T2.SlpName, T2.U_INE_Branch
        ) AS T0
        FULL JOIN
            /*** SAP - Credits by Sales Person ***/
            SELECT
            T1.SlpCode
            , T2.SlpName AS 'SalesPerson'
            , T2.U_INE_Branch AS 'Branch'
            , ISNULL(CAST(SUM(T0.LineTotal) AS decimal(15,2)), 0) AS 'TotalSales'
            , ISNULL(CAST(SUM(T0.StockValue) AS decimal(15,2)), 0) AS 'StockValue'
            FROM AU.dbo.RIN1 T0
            INNER JOIN AU.dbo.ORIN T1 ON T1.DocEntry = T0.DocEntry
            LEFT JOIN AU.dbo.OSLP T2 ON T2.SlpCode = T1.SlpCode
            WHERE T1.DocDate >= '2014-08-01' AND T1.DocDate <= '2014-09-01'
            GROUP BY T1.SlpCode, T2.SlpName, T2.U_INE_Branch
        ) AS T1
    ON T1.SalesPerson = T0.SalesPerson
    Currently I am not getting correct results (which I can do through a UNION), but am instead seeing NULLs scattered throughout, as shown below...
    (I have blacked out certain details to keep the company I work for anonymous)
    My question is: are NULLs unavoidable in this scenario simply because of the nature of JOINs? I have tried a 'JOIN' rather than a 'FULL JOIN' but instead of seeing all of the Sales People I only see Sales People who do not have NULLs, which looks nice but is not particularly accurate.
    Any help and suggestions here will be greatly appreciated.
    Kind Regards,
    David

    Hi David,
    You can try something like this:
    to avoid null
    Type in each field the keyword isnull, IsNull((T0.TotalSales - T1.TotalSales), 0) AS 'Total Sales' 
    or something like this
    SELECT T0.[SlpCode], T0.[SlpName], (Select Sum(T1.doctotal) from oinv t1 where t1.docdate between '???' and '???' and T0.slpcode = t1.slpcode)  - (Select Sum(T2.doctotal) from orin t2 where t2.docdate between '???' and '???' and T0.slpcode = t2.slpcode) as Sales FROM OSLP T0
    Hope it helps
    Kind regards,
    Augusto

  • LOA Approval notification should show Leave Occurance and YTD totals

    LOA Approval notification should show Leave Occurance and YTD totals for manager and HR Specialist???
    Hi this is very Urgent
    Thanks

    Hi,
    Please post your question in [Human Resource Management (HRMS)|http://forums.oracle.com/forums/forum.jspa?forumID=113] forum, you would probably get a better/faster response.
    Regards,
    Hussein

  • % of Total Sales

    Hi,
    How to calcuate % of Total Sales i.e  <b>Sales / Total Sales</b>  using calculated key figure.  
    I was trying to use  %CT <operand> but in the formula editor of Calculator key figure I didn't find %CT function.. there is only % function.
    Please help me how to get %CT function in formula editor or How to get the % of Total Sales.
    Thanks in advance...

    Hi Samarth,
    You can find this function if you create a formula locally in the query. Do not create this as a CKF (On the left hand side ) as this function is not available there.
    Hope this helps...

  • How to get Total Sale and Total Revenue?

    Hi,
    I have received requirement to calculate Total Sale and Total Revenue.
    what is actual difference between total sales and Total revenue?
    Is there any report or query in EBS R12 from which we can find total sale and total revenue?
    Thanks,
    Kapil
    Edited by: Kapil Mistry on Aug 2, 2012 12:10 AM
    Edited by: Kapil Mistry on Aug 2, 2012 12:11 AM

    Hi,
    Can I use Receipt details to get total revenue i.e actual income from customer ?
    Please check the following query.
    SELECT code_combination_id,
    ra.applied_customer_trx_id,
    trx_number,
    SUM( NVL( line_applied, 0 )) line_receipt,
    SUM( NVL( tax_applied, 0 )) tax_receipt,
    SUM( NVL( freight_applied, 0 )) freight_receipt,
    SUM( NVL( amount_applied, 0 )) total_receipt
    FROM ar_receivable_applications_all ra,
    ra_customer_trx_all trx,
    ar_cash_receipts_all rcpt
    WHERE
    applied_customer_trx_id = trx.customer_trx_id
    AND ra.cash_receipt_id = rcpt.cash_receipt_id
    AND application_type = 'CASH'
    AND NVL(ra.confirmed_flag, 'Y' ) = 'Y'
    AND trx.complete_flag = 'Y'
    AND trx.org_id = 204
    AND trx.customer_trx_id = 51385
    GROUP BY code_combination_id,ra.applied_customer_trx_id,trx_number
    ORDER BY 3

  • How to get Total Sales and Total Revenue?

    Hi,
    I have received requirement to calculate Total Sales and Total Revenue.
    what is actual difference between total sales and Total revenue?
    Is there any report or query in EBS R12 from which we can find total sales and total revenu?
    Thanks,
    Kapil

    Hi,
    Can I use Receipt details to get total revenue i.e actual income from customer ?
    Please check the following query.
    SELECT code_combination_id,
    ra.applied_customer_trx_id,
    trx_number,
    SUM( NVL( line_applied, 0 )) line_receipt,
    SUM( NVL( tax_applied, 0 )) tax_receipt,
    SUM( NVL( freight_applied, 0 )) freight_receipt,
    SUM( NVL( amount_applied, 0 )) total_receipt
    FROM ar_receivable_applications_all ra,
    ra_customer_trx_all trx,
    ar_cash_receipts_all rcpt
    WHERE
    applied_customer_trx_id = trx.customer_trx_id
    AND ra.cash_receipt_id = rcpt.cash_receipt_id
    AND application_type = 'CASH'
    AND NVL(ra.confirmed_flag, 'Y' ) = 'Y'
    AND trx.complete_flag = 'Y'
    AND trx.org_id = 204
    AND trx.customer_trx_id = 51385
    GROUP BY code_combination_id,ra.applied_customer_trx_id,trx_number
    ORDER BY 3

Maybe you are looking for

  • How can I modify datas on one OpenLDAP server

    Hello, I am testing Leopard server 10.5.2 ; we have one open ldap server on our network with more than 700 users and I can access to it on the workgroup manager. Unfortunately I can't modify the datas which are on the open ldap server (only with Work

  • Grant access to all the views created in user schema to another schema

    How to grant access for all the views created in own HAGGIS schema to comqdhb schema on the HAGGIS database. Oracle Grant Privileges =============== Object privileges assign the right to perform a particular operation on a specific object I read that

  • Problems with touchpad

    Hi, I have and HP dm4-1065dx. Recently the track pad has been giving me problems. It's still following my finger and registering when I tap on on it to click, but if I try to click using the two buttons on the bottom, the left click works erratically

  • Audio from a recorded video

    I record a video with my playbook and the only audio is pulsating static. My son's playbook is doing the same thing. Restarting it doesn't help. How do we fix this?

  • I Tunes 6.0 two seconds break when hearing songs

    Since I updated to I tunes 6.0 I am not able to hear my songs in a clean way because there is always a break/interruption of 1 or 2 seconds just after the beginning of each song. I have Windows XP and I already tried twice to download again the Itune