How to get 2014 and 2015 sales as cross tab report in sqlserver. Please help

I have the following data attached herewith salesdata.xls and I would like to generate the report same as I attached herewith.Please help to generate the proper sql to get the report
Regards
polachan

Hello Polachan,
To achieve the expected output, you can reference the below sample.
CREATE TABLE SalesTbl
Customer VARCHAR(99),
[Date] DATE,
Sales INT
INSERT INTO SalesTbl
VALUES
('xxxx','20140101',20),
('xxxx','20140201',20),
('zzzz','20140301',30),
('yyyy','20140401',20),
('xxxx','20150101',20),
('xxxx','20150201',30),
('zzzz','20150301',20),
('yyyy','20150401',60),
('aaaa','20150401',70),
('bbbb','20140401',40)
;WITH Cte AS
SELECT DATEPART(YEAR,[Date]) [Year],Customer,Sales FROM SalesTbl
SELECT Customer,ISNULL([2014],0) Sales_2014,ISNULL([2015],0) Sales_2015 FROM Cte
PIVOT
SUM(Sales) FOR [Year] IN([2014],[2015])
) AS PVT
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support

Similar Messages

  • Hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    if you are signed in to iTunes with your AppleID, click on the AppleID > view account > payment information > enter in your information

  • I try to restore my iphone in recovery mode but didn't get it and now can not come out of recovery mode please help me

    Hi I had perches one iphone4 from Hong Kong last month but after coming back i try to restore my iphone but it's give error 3194 then i try to restore it in recovery mode but still can not restore error -1 and now i cannot get out of recovery mode please help me to shovel this problem.

    Are you running modified software on your phone?  This error seems to be common if the firmware has been modified and you're trying to restore the phone again. 

  • My default photo viewer and default jar opener both result in the picture of the  icon getting big and then disappearing without opening a picture/program. Please Help.

    Please help. I have tried redownloading java and attempted to open the jar file with Terminal. Nothing is working.

    First, uninstall "SuperTV" (whatever that is) according to the developer's instructions. It isn't working and it's filling the log with noise.
    If you have more than one user account, these instructions must be carried out as an administrator.
    Launch the Console application.
    Step 1
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Enter "BOOT_TIME" (without the quotes) in the search box. Note the timestamps of those log messages, which refer to the times when the system was booted. Now clear the search box and scroll back in the log to the last boot time when you had the problem. Post the messages logged before the boot, while the system was unresponsive or was failing to shut down. Please include the BOOT_TIME message at the end of the log extract.
    Post the log text, please, not a screenshot. If there are runs of repeated messages, post only one example of each. Don’t post many repetitions of the same message. When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    PLEASE DO NOT INDISCRIMINATELY DUMP THOUSANDS OF LINES FROM THE LOG INTO A MESSAGE. If you do that, I will not respond.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.
    Step 2
    Still in Console, look under System Diagnostic Reports for crash or panic logs, and post the most recent one, if any. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • Row and column heading in cross tab report

    Hi Gurus,
    Is it possible to leave column headings and row headings in a crosstab report blank?
    Pooja

    Hi,
    You could either suppress the Column Headings by unchecking
    Tools-->Options-->Column Heading or Making the background color and the font color of the cell to be same ( gray ), thereby making it invisible, though it is actually there.

  • How to get Changed fields in Sales order to create a report

    Dear Gurus,
    How to get the log from sales order for the change of particular field.
    In my scenario, If an user remove the delivery block from sales order I want to capture the date on which this delivery block
    is removed and by whom (User)?
    I know that I can get the log of change but can I get in the form of field updates because further I want to use that date and user name to create a report.
    I hope u got my query. Please reply soon that I can create a report.
    Thanks in advance.
    regards,
    Sanjay

    Hi
    You can use the table CDPOS for tracking the changes at the Table level with the Sales order number
    or Else you can also use AUT10 transaction to track the logs/chanages with START DATE, END DATE and the Transaction code in your case it is VA02
    Please check and revert back
    regards,
    santosh

  • How to get max and min salary in a table

    How to get max and min salary in a table

    SQL> select max(sal),min(sal) from emp;
      MAX(SAL)   MIN(SAL)
          5512        800
    SQL>

  • Can we post entries in 2014 and 2015 fiscal years simultaneously

    Hi,
    Now we are in fiscal year 2015.Still postings are going on for FY2014.Not yet done any year end activities for 2014.Client is asking to open posting periods for fiscal year 2015.They want to post in fiscal years 2014 and 2015 as well simultaneously. Is it possible? If possible,what are the precautions we need to take ?
    Thanks

    Hi
    Yes if you have special period defined for 2014
    or keep both Fiscla period open in FI .
    in MM you should be able to post only in period 12 of fiscal year 2014 . so its depend on what sort of entriews you want to post

  • I have a macbook pro and I connected a new iphone to my computer. Somehow all my pictures in the iphoto app deleted. How can I get them back, and no I do not have my TimeMachine On. Please help!

    I have a macbook pro and I connected a new iphone to my computer. Somehow all my pictures in the iphoto app deleted. How can I get them back, and no I do not have my TimeMachine On. Please help!

    If you are running Lion then all drivers are distributed through Software Update. You do not need to install anything, other than to install the printer in System Preferences > Print & Scan. If you already added the printer while it was connected using USB, you might want to delete it and set it up again wirelessly to avoid confusion. Or, give them two distinct names e.g. "Photosmart D110 (USB)" and "Photosmart D110 (wireless)".
    All scanning functions are now performed using Preview, but you can also access the scanner through the same Print & Scan preference pane, or with Image Capture.
    This HP document may help explain how driver software is distributed now:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03079365&cc=us&dlc=en&lc=en &product=4144493&tmp_track_link=ot_search#N108

  • I was updating software and suddenly my IPHONE  started asking for I tunes on mobile screen ,  how can  i  get by screen back or How i can restore without loosing data , I m more worried about data , Please help in resolutio

    i was updating software and suddenly my IPHONE  started asking for I tunes on mobile screen ,  how can  i  get by screen back or How i can restore without loosing data , I m more worried about data , Please help in resolutio

    What exactly are you seeing on the phone's screen ? If the iTunes icon and cable then the phone is in recovery mode, in which case it's too late to take a new backup or to copy any content off the phone - you will have to connect the phone to your computer's iTunes and reset it back to factory defaults, after which you can restore to the last backup that you took or just resync your content to it

  • How to get gui_download and gui_upload with popup filename?

    how to get gui_download and gui_upload with popup filename?

    Here is a short example.
    report zrich_0003 .
    data: ifiletab type filetable.
    data: xfiletab like line of ifiletab.
    data: xstring type string.
    data: rc type i.
    data: itab type table of string.
    data: xtab type string.
    start-of-selection.
      call method cl_gui_frontend_services=>file_open_dialog
        changing
          file_table              = ifiletab
          rc                      = rc.
      read table ifiletab into xfiletab index 1.
      xstring = xfiletab-filename.
      check not xstring is initial.
      call method cl_gui_frontend_services=>gui_upload
        exporting
          filename                = xstring
      changing
        data_tab                = itab.
      loop at itab into xtab.
        write:/ xtab.
      endloop.
    Regards,
    Rich Heilman

  • How to get nodes and its attributes of an XML file usiong DOM parsing?

    how to get nodes and its attributes of an XML file usiong DOM parsing?
    i am new to XML parsing.......
    Thanking you........

    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;      ...
    //Setup the document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
         Document doc = docBuilder.parse (new File("MY_XML_FILE.xml"));
    //get elemets by name
         String elementValue = doc.getElementsByTagName("MY_ELEMENT").item(0).getTextContent();
    //This method can return multiple nodes, in this instance I get item(0) , first nodeRead the api for other methods of getting data.

  • How to get vendor and company code based on logistic invoice document

    how to get vendor and company code based on logistic invoice document in abap/4?

    Hello Kumar
    When you call BAPI_INCOMINGINVOICE_GETDETAIL using
    INVOICENUMBER = <number of invoice>
    FISCALYEAR = <fiscal year>
    the returned HEADERDATA contains what you are looking for:
    HEADERDATA-COMP_CODE
    HEADERDATA-DIFF_INF
    Regards
      Uwe

  • How to get tools and other bars back in view after deleting show-bar?

    How to get tools and other bars back in view after deleting show-bar?

    Hello Jouko.
    You can go into View > Toolbars and select the ones you want to see. If you can't see the menu bar you can simply tab ALT on your keyboard (I think F10 works too) to show it.

  • How to get instrument and plug in files to logic8?

    How to get instrument and plug in files to logic8?
    I lost mine in a hard drive crash.
    I cant use my DVD jam pack
    This is my spec
      Modellnamn:          iMac
      Modellidentifierare:          iMac8,1
      Processornamn:          Intel Core 2 Duo
      Processorhastighet:          2,4 GHz
      Antal processorer:          1
      Totalt antal kärnor:          2
      L2-cache:          6 MB
      Minne:          3 GB
      Busshastighet:          1,07 GHz
      Boot ROM-version:          IM81.00C1.B00
      SMC-version (system):          1.29f1
    iMac, OS X Mountain Lion (10.8.2)

    I think you want to get the latitude and longitude information of client accessing the web application. In the web application you cannot directly get the client location information as the nature of the web application is different from windows applications.
    I advise you to develop a Silverlight component and in that Silverlight component use geolocation classes to get client location. Please refer this article for getting data in Silverlight http://www.c-sharpcorner.com/UploadFile/82b980/getting-geo-location-of-user-in-silverlight/
    And once you get the location information you can send that data back to ASP.net webpage or call any javascript method as shown here http://ovaismehboob.wordpress.com/2013/06/22/bridging-data-between-asp-net-and-silverlight/
    Hope this helps!
    Ovais Mehboob Ahmed Khan http://ovaismehboob.wordpress.com

Maybe you are looking for

  • Time Machine Failure - Unable to  create backup directory

    I've been using time machine for months with no problems. It seems like since I went to the 10.5.2 update I started having problems. Time machine fails and says a problem occurred creating a backup directory. I'm running an external drive formated to

  • Shutdown ports that is not in use for a while using LMS 4.x

    Hi, Is there a way to disable switch ports that has not been in use for a while using LMS 4.x Your assistance would be much appreciated. Regards, Clifton

  • SharePoint 2013 Search Errors

    I'm working on a single server SharePoint 2013 Enterprise Server. The search service application was provisioned successfully. When I attempt to run a crawl on my content source, I'm receiving a few thousand instances of the following error in the cr

  • How to monitor the size of message payload processed

    Hi all, where could i find the size of the message payload processed in monitor? i want to check the volumn of the payload, such as how much kb thanks in advance

  • Group Email-Undelivered Mail

    I have various groups setup up on our server with users added. When I send an email to the group the members of that group are receiving my message, so I believe I have the correct settings for group emails. The problem I'm having is that after a few