June 30, 2016 at 2:51 pm
How would write the below Ms.Access code into sql server using the pivot function?
TRANSFORM Count([101_Test].AdmitNumber) AS CountOfAdmitNumber
SELECT [101_Test].CCSCategory, Sum([101_Test].diffAdmitDays) AS SumOfdiffAdmitDays, Count([101_Test].AdmitNumber) AS CountOfAdmitNumber1
FROM 101_Test
GROUP BY [101_Test].Category
PIVOT [101_Test].AdmitIndICT;
July 4, 2016 at 10:40 am
What have you tried so far.
You might be better off giving us some sample data and the desired output.
PIVOT works in much the same way as in Access:
You need a pivot key field and the row fields that will turn into the columns of the pivot key.
July 5, 2016 at 5:27 am
You could just use the crosstab technique in SQL Server. I find they're generally faster than pivot. Jeff has an article on the subject at http://www.sqlservercentral.com/articles/T-SQL/63681/ that's a really good place to start learning them.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy