Results 1 to 6 of 6

Thread: Sales report per SKU

  1. #1
    Join Date
    Apr 2012
    Posts
    167

    Default Sales report per SKU

    Hi

    Anybody know of a way to extract a report of the total sales of each SKU for a required date range?

    Example - A total sales report for a year of all SKU's that have sold?


  2. #2
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    432

    Default

    Very rough (and you might want to check that I've used the correct product price field) but something like this to get you started...

    Code:
    select os.OrderedProductSKU, convert(DECIMAL(15,2),SUM(os.OrderedProductPrice)) totalsales 
    from Orders_ShoppingCart os
    join Orders o on o.OrderNumber = os.OrderNumber
    where o.OrderDate between '01-Jan-2011' and '01-Jan-2012'
    group by os.OrderedProductSKU 
    order by 2 desc

  3. #3
    Join Date
    Apr 2012
    Posts
    167

    Default

    Just needed the

    USE [dbname]
    GO

    before. Seems to work like a charm. Is it also possible to include the Quantity & Ordered ProductName from within the Orders_ShoppingCart table so there is the SKU, Total amount, Product name and Quantity?


  4. #4
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    432

    Default

    Yes, you can add Qty and Product name but you need a slight SQL trick to convert the name field to nvarchar because you can't group by ntext columns:

    Code:
    select os.OrderedProductSKU, convert(DECIMAL(15,2),SUM(os.OrderedProductPrice)) totalsales,
    cast(os.OrderedProductName as nvarchar(255)) Name, SUM(os.Quantity) Qty
     from Orders_ShoppingCart os
    join Orders o on o.OrderNumber = os.OrderNumber
    where o.OrderDate between '01-Jan-2011' and '01-Jan-2012'
    group by os.OrderedProductSKU, cast(os.OrderedProductName as nvarchar(255))
    order by 2 desc
    What would be really nice is to have this type of report available in the admin pages.... but I can't do that 'pro bono' I'm afraid. Someone else here might be able to though.

    Adam

  5. #5
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    330

    Default

    You can always add it to the custom report area
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  6. #6
    Join Date
    Apr 2012
    Posts
    167

    Default

    That's great as it is thanks!

    Should be a standard report I think

    Great work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •