Query for Weekly Sales Report

Dear Experts,
I have developed the query for weekly sales report for the alert management to send out the report on every Monday as follow :
SELECT T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.[DocDate] between GetDate()-8 and GetDate()-1
The weekly report received on every Monday through email is without column total for the "Line Total".
Can the Sum of column "Line Total" to be included in the query ?
Thus, the auto send report on every Monday by alert management will display the total.
Thanks in advance for all your kind assistance.
Regards,
Clara

Ok you want it at the bottom.......
then you must must try this if you are running query generator....
Else a good option is Crystal Report.
You need to only add Group Sum.......
SELECT T0.CardCode, T0.CardName, T0.DocDate, T1.ItemCode, T1.Dscription, T1.Quantity, T1.LineTotal FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
Union All
Select '','',Null, '','Total',Null, Sum(T1.LineTotal) FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
Regards,
Rahul

Similar Messages

  • SQL Query for weekly sales

    Hi,
    This is my First table: REPORT
    with report as (
    select 'vendor_1' as vendor,to_date('1/1/2012','DD/MM/YYYY') supply_date, 'customer_1'as customer,'item_1' as item1, 110 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,120 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item1,130 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/4/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,140 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/10/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item ,200as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/23/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item,0 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/6/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,160 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/7/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,170 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/8/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,180 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/9/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,190 as cost from dual union all
    select 'vendor_1' as vendor,to_date('1/20/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,300 as cost from dual)
    THIS IS MY SECOND TABLE: TEMP_WEEK
    WITH temp_week a s(
    SELECT '01/01/2012 to 07/01/2012' AS week from dual union all
    SELECT '08/01/2012 to 14/01/2012' AS week from dual union all
    SELECT '15/01/2012 to 21/01/2012' AS week from dual union all
    SELECT '22/01/2012 to 28/01/2012' AS week from dual union all
    SELECT '29/01/2012 to 31/01/2012' AS week from dual)
    To find weekly sales i have wrote below query:
    SELECT week,vendor,customer,SUM (cost)
    FROM ( SELECT week,vendor,customer,SUM (cost) cost
    FROM (SELECT CASE
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 THEN
    '01/01/2012 to 07/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 THEN
    '08/01/2012 to 14/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
    '15/01/2012 to 21/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 THEN
    '22/01/2012 to 28/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 THEN
    '29/01/2012 to 31/01/2012'
    END
    week,vendor,customer,cost
    FROM report)
    GROUP BY week, vendor, customer
    UNION ALL
    SELECT tw.week,vendor,customer,0
    FROM ( SELECT week,vendor,customer,SUM (cost) cost
    FROM (SELECT CASE
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 THEN
    '01/01/2012 to 07/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 THEN
    '08/01/2012 to 14/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
    '15/01/2012 to 21/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 THEN
    '22/01/2012 to 28/01/2012'
    WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 THEN
    '29/01/2012 to 31/01/2012'
    END
    week,vendor,customer,cost
    FROM report)
    GROUP BY week, vendor, customer),temp_week tw)
    GROUP BY week, vendor, customer
    ORDER BY vendor, customer, week ;
    with above query i am getting below output:
    with output as(
    select '01/01/2012 to 07/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 500 as cost from dual union all
    select '08/01/2012 to 14/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 200 as cost from dual union all
    select '15/01/2012 to 21/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
    select '22/01/2012 to 28/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
    select '29/01/2012 to 31/01/2012' as week,'vendor_1' as vendor,'customer_1' as customer, 0 as cost from dual union all
    select '01/01/2012 to 07/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 330 as cost from dual union all
    select '08/01/2012 to 14/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 370 as cost from dual union all
    select '15/01/2012 to 21/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 300 as cost from dual union all
    select '22/01/2012 to 28/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 0 as cost from dual union all
    select '29/01/2012 to 31/01/2012' as week,'vendor_1' as vendor,'customer_2' as customer, 0 as cost from dual )
    Clearly I have used cross join. But I want to get same output with some other way. I dont want to use cross join and Union
    please help me in this.

    DUPLICATE!
    SQL Query help.

  • Query for daily sales by warehouse

    Hi
    I need a query for   Daily sales by warehouse.  I am only new to this and struggling with generating.
    ideally it will look like the below.     With no selection criteria as I would like to schedule the report to email out at the end of each day.
    Warehouse      Revenue      GP          GP%
    NSW               $xxxx             $xxx       35%
    Would someone mind helping
    thanks

    thankyou ,   But i have multiple warehouse and i dont want to use a selection criteria.
    to expand on the original example
    Warehouse      Revenue      GP          GP%
    NSW                 $xxxx             $xxx           35%
    QLD                  $xxx               $xx            32%
    VIC                  $xxx               $xx            32%
    Also the results should only show figures for the day the query is executed
    Any help is appreciated.
    Similar layout to this,except using query and whs code.    the below is generated using sales analysis and customer group. 

  • How to find the name of query for a given report

    Hi All,
    I am having the name of a report and i need to find out the name of query for that report . Plz tell me how to find out the name of the query for a given report.
    Thanks.
    Regards,
    Pooja Joshi.

    Use this FM
    RSAQ_DECODE_REPORT_NAME
    This FM takes program name as I/P and gives Query Name as O/P.
    This FM uses the structure AQADEF to fetch the data.
    Hope this helps.
    Regards
    Vinayak

  • Extracting the Logical sql query for the specified report  in OBIEE 11g

    Hi ,
    I want to extract the logical SQL Query for the Particular report in OBIEE 11.1.1.5.
    Any pointers related to this will be very helpful.
    Thanks,
    Sonali

    for a try please add Logical sql view to ur report it will dispaly the Logical sql for that Report..
    Hope it will helps you.

  • Bex query for BW abap report/ transaction

    Hi Experts, Here is a scenario: I developed ABAP program in BW using multiple DSOs for complex logic. Since I cannot use abap program directly in BO reports, I need to develop a query in BW for my abap program. Is it possible to develop a bex query for BW abap report / transaction in BW? I have limited knowledge on BW and BO. Please help me. Thanks in advance Raghu

    First of all thanks for your suggestion Matthew..!
    As you said, I created virtual info cube based on function module.
    In the info cube, I defined (4)dimensions and (1)key figure.
    In the fucntion module, appropriate below parameters defined and code written for the data table (e_t_data)
    CALL ZFM_XXXXXXX 
    EXPORTING   
    i_infoprov =                " Name of InfoProvider   
    i_th_sfc =                  " rsdri_th_sfc: List of Characteristics    
    i_th_sfk =                  " rsdri_th_sfk: List of Key Figures
    *   i_t_range =                 " rsdri_t_range: Range List
    *   i_tx_rangetab =             " rsdri_tx_rangetab: Table from Range List
    *   i_first_call =              " rs_bool       First Call
    *   i_packagesize = 100000      " i             Package Size 
    IMPORTING   
    e_t_data =                  " standard table:  Data Table   
    e_end_of_data =             " rs_bool       :End of Data Reached   
    e_t_msg =                   " rs_t_msg      : BW: Table with Messages
    Test:
    Right click the info cube and choose "displayed data", immediately it triggered above function module.
    when I see the import parameters data,
    no characteristcs data in i_th_sfc. But, key figures has data (1 record) in i_th_sfk.
    Not sure, Did I missed anything? Please help me.
    Thanks in advance

  • Smart Form for Monthly Sales Report

    Is any possible smart form for Monthly Sales Report
    if possible let me know....
    Phani.

    Hi Phani,
    There is no standard for this delivered by SAP. You would have to create your own form and print program.
    Sales Reports usually come out of LIS or BW. In the case of BW,  tools like Business Explorer might help you.

  • Output error in Query for Weekly report

    Hello friens,
    I want to create a report in which the user want the output of data as foloow
    net amount----
    week1 week2 week3............. and so on.
    pack1
    pack2
    pack3
    Now there are 52 weeks in a year, and in system the data is stored since 2003 till date.
    So user will want to enter the range of weeks that they want to see for e.g.
    010/2005 -- -12/2007
    Time characteristics available are
    calendar day, calendar year/month, calendar year/week, calendar year,fiscal year, fiscal year/period,posting period
    What i did is in columns for NET AMOUNT , i restricted kf with Fiscal Week and, restricted Fiscal week with Interval variable.
    Now user wants that they want to see the
    Start date of a week for monday.
    So they dont want to see
    week1 week2 week3 week4...........
    But they wanted to see
    01/01/2006   01/08/2006  01/15/2006 and so on.......
    So Please advise what needs to be done!

    Well i didnot able to do that.
    If i restrict in Calday it gives me oppurtunity to restrict with Day not monday, but monday with date..
    so for e.g. in single value restriction.
    i can restrict for Monday 8th october to Friday 12th october.
    So what can u suggest.
    If i create Interval for calday than what user will input is date.
    Plus i think what i mean to say previously is,
    User want to see the Start date of particular weeks
    Start date means date of Start Day , which is Monday.
    So for e..g. Date of monday for week 1 is 01/01/2007 then for next week monday will be 01/08/2007..
    So instead of displaying the Week as 01/2007 .to  050/2007,
    The user want to see the start date of PArticular week.
    so as follow
    01/01/2007  01/08/2007  01/15/2007  01/22/2007  01/29/2007 
    I hope u understand.
    So user want to see the aggregate sales of Week 1 and in description they want to see the Start date of that week.
    They do not want to see date by date sales.
    Please advise.

  • BEX Query for Week, MTD, YTD  for Sales data

    Hi,
    I want to display the sales data for current  Calender day, Cal week, Cal Month to date, Cal Year to Date and also for previous year Cal month, Previous Year Calender Year to Date data.
    Structure is like this. for displaying Sales data. No variables are used on selection screen regarding below structure.
    Calender Day I CalWeek I CalMonth(current) I CalMonth(previous Year) I YTD(current) I YTD(previous Year)
    Please suggest me I used the variable 0P_HAPCY is enough or I have to do any other setups.
    Message was edited by:
            Kaveri

    Kaveri,
         I think 0P_HAPCY doesn't work for all the columns. Well when the user enters date it will also have the year and month right? So what is the relevance of year entered by teh user.
    For the data for calender day, you can get directly from the user entry.
    For calweek data you need to derive week from the calday enetered by the user using customer exit.
    Similarly for month to date, and year to date.
    Use offsets on customer exit variables for previous year calmonth and previous year yera to date data.
    Hope this helps you...

  • Query for Total sales by customer

    Hi,
    I want to create a query for getting a total of all sales for all Customers for the date range entered by the user.
    How can I do it?
    Jyoti

    If I can add my thoughts.  The query from Jyoti fails for me due to the Where statement.  Try the following:
    SELECT T0.CardName, T0.Address, T1.CreditLine, T2.PymntGroup as 'Payment Terms', T1.Balance, T0.DocTotal
    FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
    WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]'
    Having said that I use the built in Sales Analysis report to get the sales by customer by date.
    regards,
    Ralph

  • SAP Query for AR Aging Report

    Hello Gurus-
    I am trying to build a query for Aging report, and would like to include something like this:
    Customer-Reference-Payment terms-Due date-Current-31-60days-61-90days-91-120days-over120days-toatal amount.
    I have an infoset which includes BSID, KNA1, KNB1. I have maintained local fields:
    Due Date  =     Baseline date + cash discount days
    Statement Date = My input date.
    Current    = Condition (DUEDTE >= STATDTE - 30) formula (Amount)
    31 - 60 Days = Condition (DUEDTE >= STATDTE - 60 AND DUEDTE < STATDTE - 30) formula (Amount)
    61 - 90 Days = similar to above
    91 - 120 Days = similar to above
    Amount  = - 1 * (If Debit credit indicator = "H" then "Amount in local currency") otherwise "Amt in Loc.Cur"
    Over 120 Days = similar to above
    When I enter a statement date of today it works hunky dory...it all looks good...my current column looks good and do the rest. When i want to run this query as of couple of months ago (if today is 12/19/08 and i wanted to run my aging report for 10/31/08) it should give me aging as of my statement date 10/31/08 but it does not. It calculates the total amount as of today. I know because of local field "Amount" where i gave amount in local currency, but how would I tell that it should pick up amount in local currency till the statement date?
    Any input in this regards is highly helpful.
    Thanks,
    RNarayan

    Hi Ram,
    On your aging report you want to see invoices which are still not paid (or still open) as of a certain date. This date is "key date". You need to define a variable for key date (which is normally system date if you run today) but it could be a past date.
    So key date is let us say Oct 31st (X) and the system date is Dec 19th. When you run the report as of Oct 31st all invoices that are posted prior to Oct 31st (posting date less than X) and are still in BSID will show on your report. There is no issue here.
    Let us say an invoice was created on Oct 25th (Y) and was paid on Nov 15th (Z). The clearing date is Z. That means if you run the aging report today this invoice will not show.
    But you want to run the report on Oct 31st. This means X is greater than Y but is less than Z.
    Clearing date and posting date are part of BSAD. Report run date is the user input and is a variable.
    With the above concept and with the help of an ABAP programmer you should be able to solve the problem.
    Regards
    Sharabh

  • Change BAPI for Weekly Expense Report using PR04

    I am looking for a way to change a Weekly Expense Report using a BAPI. I am able to create one , however , unable to change . Has anyone accomplished this before ?

    Solved on section SAP Travel Management, thread: 3567830.
    Regards,
    Gregory.

  • Can anyone share the query for inventory aging report

    Is there any standard reports for inventory aging in oracle ebs 12.1.3 ....... If not can anyone share the query for inventory aging report

    Hi,
    It may not be so simple as you are trying to reproduce the historical value.  I believe you have to create a temporary table first.  Or you may use Command feather to get the required data in advance.
    Thanks,
    Gordon

  • QUERY FOR UNINVOICED RECEIPTS REPORT

    hi all,
    can anybody help me to find the query for standard "uninvoiced receipts report" report our requirement is to develop the standard report in discoverer i am trying the query which is in "CST_UninvoicedReceipts_PVT.Start_Process"
    in this the query contains the table "cst_per_end_accruals_temp" it contains no date
    thanks in advance

    hi paarthy thanks for ur reply,
    i don't need the template of CSTACREP.rtf i need the base query for the report.
    can u please tell me that where i can get the file:CSTVURRB.pls i check it in the concurrent-->program-->executable
    there is no executable with this name.
    thanks,
    ravi

  • Query for Inventory Audit Report

    hi experts,
    I would like to create a inventory report  using Crystal Reports 2008 which looks exactly the same as Inventory Audit Report in SAP Business One 2007A
    Report requirement:
    List down all the items with its Item Code, Description, Quantity and Item Cost (easy right?)
    The only condition:
    I would like to filter my report by FromDate and ToDate.
    For example:
    Current date 15.07.2009
    If I run the report by putting in 01.01.2009 to 31.01.2009, the result will show me:
    item, with its respective info and most importantly the Quantity and Item Cost as at 31.01.2009 (similar to closing stock)
    Any query for above report?
    Please help.
    Thank you.

    Hi,
    It may not be so simple as you are trying to reproduce the historical value.  I believe you have to create a temporary table first.  Or you may use Command feather to get the required data in advance.
    Thanks,
    Gordon

Maybe you are looking for

  • Itunes install hangs due to ringtones.xib error?

    When I try to upgrade or uninstall then reinstall Itunes 7.7, I get an error statement that reads: error writing to file C:\program files\itunes\itunes.resources\ko.lproj\ringtone.nib\objects.xib. Verify that you have access to that directory I have

  • Facing a Problem while downloading the data from ALV Grid to Excel Sheet

    Hi Friends, Iam facing a problem while downloading the data from ALV Grid to excel sheet. This is working fine in Development server , when comes to Quality and Production servers I have this trouble.    I have nearly 11 fields in ALV Grid and out of

  • Annual requirment

    Hi For Material Codes with MRP Type as " VB - Manual reorder point planning " system generated Purchase Requisition Qty is based on value maintained in fileds Re-order point, Lot Size. Our requirement is as below - Presently for Materials with MRP ty

  • Item Level Permission does not work as designed

    Here is the problem.  We have a site with a site members group with created permission level called vnContributor that differs from contributor in that they cannot edit delete items or versions, or create alerts.  We have a site owners group who have

  • Cant boot HELP

    cant boot after i ran out of battery during update later when i recharged it i left macbook on for 12hours without moving off the boot screen (the grey apple with the circle loading thing) i tried repairing it with mac install disk but nothing. not s