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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 how can i acheive this result set

Author  Topic 

sanjay_jadam
Yak Posting Veteran

53 Posts

Posted - 2006-01-23 : 02:35:50
Hi all,
I have a table I which these fields are present
EnrollmentId
PersonID
EnrollmentDate
ProductID

I have to find the count of person who enrolled for a particular product from 3 month ago, means I have to find person who enrolled in past three month.
User will enter only Year and I have to show data from past year to current year.
Means if user will enter 2005 then I have to show data from 2004 to 2005

Please help me

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-23 : 02:57:15
>> find the count of person who enrolled for a particular product
you can use select count(*) with group by PersonID

>> for a particular product from 3 month ago
use dateadd(month, -3, getdate()) to calc 3 mths ago date. Compare it with your column

>> User will enter only Year and I have to show data from past year to current year.
>> Means if user will enter 2005 then I have to show data from 2004 to 2005
Is your requirement 3 months ago or past year to current year ? ? ?

-----------------
'KH'

I don't do homework
Go to Top of Page

sanjay_jadam
Yak Posting Veteran

53 Posts

Posted - 2006-01-23 : 03:05:40
i have to show data like this
User will enter a Year

Plan jan2004--Feb2004----upto--Dec 2005
1------20---10---------------------20
2------20---10---------------------20
3------20---10---------------------20

these value (10 or 20)will calculate as
If i want to calculate count of person for jan 2004
then i have to calculate count of person from past three month means from Nov2003,Dec2003,Jan2004 months
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-23 : 03:13:44
See the FGA on cross tab / pivot table http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210

----------------------------------
'KH'

I do work from home but I don't do homework
Go to Top of Page
   

- Advertisement -