Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: Sales report per SKU

  1. #1
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    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
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    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
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    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
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    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
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    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
    Skriver is offline Senior Member
    Join Date
    Apr 2012
    Posts
    188

    Default

    That's great as it is thanks!

    Should be a standard report I think

    Great work!