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.
Author |
Topic |
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-06-28 : 08:01:43
|
Hello everyone,I am facing a very serious problem.I will try my best to explainI have two tablescreate table RegMain ( RegID int, SiteID int, ResourceName varchar(10), CreatedOn datetime )create table RegDPMALiveStatus ( RegID int, RegStatus varchar(10), UninstDate datetime )Joining these two tables we may get the information like belowRegID ResourceName SiteID CreatedOn UninstDateNow When any resource is created then it get inserted intoRegMain with the createdOn date and at the same time in RegDPMALiveStatus with UninstDate NULLNow When any resource is uninstalled then Date is being updated in UninstDate.Now if again same resource will be created then it get inserted into RegMain with same resourceName and different RegIDNow i have to get all the resources which where Uninstalled and Reinstalled in the same month which is may.this time I have to check Uninstdate and CreatedOn or ResourceName insted of RegID as RegID will be different.I hope i was very clear to make you understandPlease help me out..Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-06-28 : 10:08:11
|
If the regids still link the tables, then this should get you startedselect main.*from #regMain maininner join #RegDPMALiveStatus statuson main.regid = status.regidwhere main.created >= dateadd(month,datediff(month,0,createdon),0) and < dateadd(month,datediff(month,0,UninstDate) + 1,0) JimEveryday I learn something that somebody else already knew |
 |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-06-29 : 02:45:02
|
I am sorry but i m not able to understandwhat you have done in the query.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
|
|
|
|