Datename(Month) - need to change it to show Dates across the Year

Hi,
Just wondering if anybody can help, I've tried using the selectdatename(dw,getdate())
function replacing the Month,getdate())
to show results on a daily basis, it doesn't seem to work.
I also need to show all options in a column list from field dbo.trainee.scheme
My current query -
SELECT
* FROM 
Select
LEFT (DATENAME(MONTH,dbo.epidata.TR_END),3)
AS Mnth,
count(distinct
epidata.ident)
as 'Learners'
FROM [Babington1].[dbo].[epidata]
join [Babington1].[dbo].[Trainee]
on [Babington1].[dbo].[epidata].[ident]
= [Babington1].[dbo].[Trainee].[ident]
 WHERE
dbo.epidata.TR_END
>= '20140801'
AND dbo.epidata.TR_END
< '20150801'
 ----AND dbo.Trainee.SCHEME = 'apps'
group
by dbo.epidata.TR_END
)s
PIVOT
SUM(learners)
FOR  Mnth
IN
([Aug],[Sep],[Oct],[Nov],[Dec],[Jan],[Feb],[Mar],[Apr],[May],[Jun],[Jul])
)P
My current results look like
         Aug Sep Oct Nov Dec
1        302 211 231 50 NULL
I would like my final result to look like -
                       Wk1 | Wk2 | Wk3 |  Wk4  |  Wk5
Scheme Title      1          2        0        1         1
Scheme Title 
Scheme Title

if you want weeks what you need is this
SELECT * FROM
Select 'Wk' + RIGHT('00' + DATENAME(Wk,DATEADD(wk,DATEDIFF(wk,0,dbo.epidata.TR_END),0)),2) AS Wk,
count(distinct epidata.ident) as 'Learners'
FROM [Babington1].[dbo].[epidata]
join [Babington1].[dbo].[Trainee] on [Babington1].[dbo].[epidata].[ident] = [Babington1].[dbo].[Trainee].[ident]
WHERE
dbo.epidata.TR_END >= '20140801'
AND dbo.epidata.TR_END < '20150801'
----AND dbo.Trainee.SCHEME = 'apps'
group by DATEDIFF(wk,0,dbo.epidata.TR_END)
)s
PIVOT
SUM(learners) FOR Wk IN
([Wk01],[Wk02],[Wk03],[Wk04],...,[Wk53])
)P
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to change charts default   "show data label" properties.

    I tried to change some defult properties of charts.I changed font, color etc, manipulating pcxml file. But i can't fount defult behaviour of data lables. I want to change defult chart "Show Data Labels" properties as "Alwasy" , not "On rollover".
    Thanks for all reply

    You need to go to the General Properties : Data Labels: Always
    Thanks
    Prash

  • I need to change my e-mail address in the app store to enable me to get updates and buy more. How does this happen??

    I need to change my e-mail address in the app store, how does that work??

    On apple website, seraching on support, the article HT1918 explains.
    Log into your apple ID and edit your personal information, where email can be changed as well. All applications as itunes stores, apple store and icloud use this same apple ID, so be aware of this.
    I hope I was helpful !

  • I am creating a web form from a template and I need to change a field. It is just a text field at the moment but I need to change it to a field that the customer can fill in. How do I do this?

    I am creating a web form from a template and I need to change a field. It is just a text field at the moment but I need to change it to a field that the customer can fill in. How do I do this?

    See this thread:
    http://answers.acrobatusers.com/Is-add-instructional-text-text-field-disappear-clicked-q19 5078.aspx

  • I need to change a new Apple id on the iPad but  I can not sign out the old Apple id on my iPad because I forgot the password and sec

    I Need to change a new Apple id on the iPad but I can't sign out the old one because I forgot the password and the security question.

    Yes, you can just log out of iCloud on the mini (Settings>iCloud> Sign out) and nothing will be affected as long as the iPad is not restored from any backup after that. Though if you're giving her the iPad I would highly recommend moving the pictures to your iPad (via this page) so that the mini can be reset and set up under your daughters ID to avoid Activation Lock in the future.
    What to do before selling or giving away your iPhone, iPad, or iPod touch - Apple Support
    -Ethan

  • I need to change my Cursor when I rollover the Image, Any feature is there in Muse...?

    I need to change my Cursor when I rollover the Image, Any feature is there in Muse, I searched it, But no use, Is there's any plugin is there to do...?

    Click here and request assistance.
    (89404)

  • Why is the decline button for phone calls not available when the phone is locked? I need that button and it shows only when the phone is not locked on iOS 7

    Why is the decline button for phone calls not available when the phone is locked? I need that button and it shows only when the phone is not locked on iOS 7

    Yep. You need to touch the sleep/power button once to silence the ring, and twice in order for the call to go directly to Voicemail.
    Personally, I dont understand why Apple eliminated this. If you wish to give Apple feedback, do it here:
    www.apple.com/feedback

  • Show difference between the years and how much money increased ever year

    Hi everyone
    I need to make the following code show how many years it took for it to reach its required goal.
    show difference between the years and how much money increased ever year. ..
    I am totally confused at the moment... any help would be greatly appreciated...
    declare
    a number(9):=1000;
    b number(9);
    c number(9);
    d number(9);
    begin
    for d in 2012..2099
    loop
    dbms_output.put_line(a||' '||d);
    if a >2000 then
    exit;
    end if;
    a :=a + a*10/100;
    end loop;
    end;
    Result for above query:
    Price Years
    1000 2012
    1100 2013
    1200 2014 etc...
    I need to show the amount of years it took to reach its goal, which was $2000
    and also the change in price, how much it increased every year...
    Thanks
    Umair

    960361 wrote:
    Hi everyone
    I need to make the following code show how many years it took for it to reach its required goal.
    show difference between the years and how much money increased ever year. ..
    I am totally confused at the moment... any help would be greatly appreciated...
    declare
    a number(9):=1000;
    b number(9);
    c number(9);
    d number(9);
    begin
    for d in 2012..2099
    loop
    dbms_output.put_line(a||' '||d);
    if a >2000 then
    exit;
    end if;
    a :=a + a*10/100;
    end loop;
    end;
    Result for above query:
    Price Years
    1000 2012
    1100 2013
    1200 2014 etc...
    I need to show the amount of years it took to reach its goal, which was $2000
    and also the change in price, how much it increased every year...
    Thanks
    UmairHow do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Imported ical from outlook and the date across the top of the weekly view all show the date i imported..

    imported ical from outlook and the date across the top of the weekly view all show the date i imported..

    I'm confused, what does iCal have to do with this, it seems as though you went from Outlook to Entourage, is that correct?

  • I'm typing dates across the top row. I want the date to be 12/13 and the program changes it to Dec. 13. It is making me mad. How do I get it to stop doing the change? I want a numerical number.

    How do I get the numbers program to type a numerical date across the top row? It wants to change it to Dec. 13 instead of 12/13.

    Amy,
    I hope that you can forgive Numbers for converting the date you enter as 12/13 into the default format of "December 13, 2011", one that is popular with many users.
    You can change to any of the supported date formats by using the Cells Inspector, Date and Time options.
    Select the top row of cells and use the inspector to set the format. You may do this before or after making the entries.
    Jerry

  • In my account I need to enter my credit card data, but the computer says: session is running out of time. What can I do?

    In my account I need to enter my credit card data, but the computer says: session is running out of time. What can I do?

    Connect the device to your iTunes library in Recovery Mode using the instructions in this Apple support document and restore it to factory settings.
    http://support.apple.com/kb/ht1808
    B-rock

  • BAPI_PROCORD_CHANGE need to change GLTRS (scheduled finish date)

    Hello -
    I am writing a program where I need to change the scheduled finish date (field GLTRS) in a process order (transaction COR2).  I would like to use the bapi BAPI_PROCORD_CHANGE but it does not contain that field in the input structure. 
    Does anyone have any ideas how I can change that field without writing a BDC?  I am also curious to know why it was excluded from the bapi in the first place.
    Thanks!

    Hi Ferry,
    Thank you for your quick reply!
    That is very close to what I need, but it only updates GSTRS (scheduled start) and I need to update GLTRS (scheduled finish). 
    Can you think of any other suggestions?  I have also looked at BAPI_ALM_ORDER_MAINTAIN, but it doesn't have GSTRS as an input either, and doesn't seem to work for the order type I need.
    Thanks again,
    Susanna

  • I need to change my region from canada to the us

    I received a canadian gift card for I Tunes.  I had to change my address to a canadian one in order to use the gift card.  Now I need to change it back but it will not because a valid credit card is not on file.  It will not let me change the credit card because had to put in a fake canadian address.  Help

    There's probably not going to be anything anyone here can do to help. You'll need to contact the iTunes Store and ask for assistance:
    http://www.apple.com/support/itunes/contact.html
    I have no idea whether they can or will help since you were deliberately violating their terms of use.
    Note that you cannot change countries if you have any credit balance left from the gift card. Only the iTunes Store can help in such a circumstance.
    Good luck.

  • Need to change my security e-mail as the account i was previousily using has been deleted

    i need to change my security e-mail address as the account i was previousily using using has been deleted. I've been wanting to buy a few albums in iTunes before i go away (no reception in the area I'm going).
    just someone please, please help me!

    If you know the answers to your security questions, then from http://support.apple.com/kb/HT5312 :
    Navigate to appleid.apple.com using your web browser.
    Click "Manage your account"
    When prompted, sign in using your Apple ID and password.
    Click Password & Security
    You'll be asked to answer 2 of your 3 security questions before you can make any modifications. If you are unable to remember your answers, you can choose to send an email to your rescue email to reset your security questions.
    After you've validated your identity by correctly answering your security questions, click Edit to the right of your rescue email address.
    Once you've finished editing your rescue email address, click the Save button directly below the email field.
    If you can't remember your answers then you will need to contact iTunes Support / Apple in your country to get the questions reset, before you can then use the above steps for potential future use.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699

  • Why does my Macbook show it's the year 2554 BE? How can I fix it?

    My Macbook stopped showing the correct year. It shows that it is the year "2554 BE" I don't even know what BE stands for!
    The time, month, and day are all right but the year keeps bugging me!
    The text is in spanish but I guess we all get the same window.
    1) I tried changing the year but the lowest it can go is "2512 BE".
    2) I tried Reseting the time and date but it didn't work either.
    3) And I also tried setting the Time and Date to automatically change and took me back to "2554".
    What else can I do?
    P.S. My macbook is up to date. I have the Version 10.6.7
    I WOULD REALLY APPRECIATE YOUR HELP!!
    Message was edited by: Neymgm I guess this is a better way to read it.
    Message was edited by: Neymgm

    Hello,
    B.E = Time Format, used in most Asian Countries. Means Buddhist.
    Try and tick the "Set Date & Time Automatically Box". Set it to the appropriate setting.
    Where abouts did you buy your Mac from?

Maybe you are looking for