Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Counting number of people accrued each month

Author  Topic 

eganopat
Starting Member

1 Post

Posted - 2015-03-06 : 09:06:55
Hi,

I am having a problem transforming a data set to the structure I need. Any suggestions of how to go about this would be great.

I have data in the following format.

Id Visit1 Visit2 Visit3 Visit4
1 2Mar2010 27Mar2010 24Apr2010 8Jul2010
2 2Apr2010 3May2010 4Jun2010 11Jul2010

I need to transform it into a table which gives a count of the number of subjects at each visit at the end of each month.
For example, in March there will be 1 subject at visit 2. In April, there will be a total of 2 subjects, 1 at visit 1 and 1 at visit 3. In May there will be 2 subjects, 1 at visit 3 and 1 at visit 2, etc.


Thanks for looking at this.

Hi,

Here is the table I was hoping to produce.


Date.....Subjects.......Visit1.....Visit2.....Visit3.....Visit4
March....1.............................1
April......2...................1.........................1
May.......2.............................1..............1
Jun.......2............................................2
Jul.......2...........................................................2

Thanks.

jleitao
Posting Yak Master

100 Posts

Posted - 2015-03-06 : 13:41:55
can you post of your expected output?

------------------------
PS - Sorry my bad english
Go to Top of Page
   

- Advertisement -