Summarising MONTH value

  • Hello

    I have a simple statement that starts:

    SELECT a.product, MONTH(a.saledate) AS Month, Count(*) AS Total

    Which yields, for example,

    Product Month Total

    Bike 8 1000

    Please can anyone advise if it's possible to add the month's name to this query and also, is it possible to get a monthly total to appear as well?

    Thanks

  • Use the DATENAME() function.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • For your second requirement you can achieve that using a window function. If you want an example please provide DDL and sample data. Luis' signature has links on how best to post those.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • Y.B. (8/10/2016)


    For your second requirement you can achieve that using a window function. If you want an example please provide DDL and sample data. Luis' signature has links on how best to post those.

    As this is a reporting services forum, I believe that the window function is not needed. Just need to add a group to the report.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply