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 |
|
mitasid
Yak Posting Veteran
51 Posts |
Posted - 2006-07-23 : 23:20:04
|
| Hi guysI have not been able to solve this problem from quiete a long time.My question is i have two tables- practices and practitionerthe practice table contains information on the practices that are performed by practitioners in different cities and a field called CostAnd an additional information whether the practitoner is full time or part timeA practitoner can work on any number of practices , full time or part time.He can even work full time on more than one practice or any combinationThe pattern of this table is as followsPractice-TableCity PractitionerName PracticeName Cost fulltime(y/n)A Smith XYZ $1233 yA Jones ABC $300 nB Clare QWE $1111 y......................................The second table contains the practitioner data such as a practioner is working on how many practices, what was the start date,end date and weather he was full time or part time ...PractitionerTableCity PractitionerName Practice StartDate EndDate Fulltime(y/n)A Smith ABC 12/12/2004 Null yA Smith XYZ 03/09/2005 Null nB Clare AbX 03/08/2000 03/07/2001 nB Clare ASD 05/09/2000 Null y....................................................now i have to distribute the cost according to the type of service (full time or part time)The calculation is as followsif a doctor is working as full time in more than one practice, the cost gets distributed equally in all the practicesactually these costs are paid by the disttrict boards but we are not concerned about that..Our job is just to distribute the cost amongst the practices by the practitioners. If a Practitioner works in two practices and is not recorded as a non-full time practitioner in any of the two practices, 50% of their expenditure will be assigned to Practice A and 50% of the expenditure will be assigned to Practice B.Example 2: If a practitoner is working full time in practice A and working as a non-full time practitioner in one other practice B, then 75% of their expenditure will be assigned to Practice A and 25% of the expenditure will be assigned to Practice B.Example 3: If a practitioner is working full time in practice AA and working as a non-full time practitioner in three other practices , then 62.5% (50% + (50%/4)) of their expenditure will be assigned to Practice A and 37.5% (50%/4*3) of the expenditure will be assigned to Practice B.hope this helps..I am really struggling with this problem..how shall i do this??? |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-07-24 : 01:06:57
|
| Can you post some sample data and the table defs?I assume the costs table has a date column? Otherwise you can't reliably link it to the practises table. Send it to my email address (see profile) if it's too big to fit here.Cheers,Tim |
 |
|
|
mitasid
Yak Posting Veteran
51 Posts |
Posted - 2006-07-24 : 23:02:02
|
| hi The practice table(Cost) does not have any dates..however we have to assume that the name of the practitioners and practices must be the part of the practitioner table. which means practitioner is sort of a reference table where the names of all the practitioner and practices are listed.. Here is the DLL of my tablesPractitioner TableUSE [Practitioner]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Practitioner]([city] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[PracticeName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[PractitionerName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[Practitioner_Startdate] [datetime] NULL,[Practitioner_Enddate] [datetime] NULL,[fulltime] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL) ON [PRIMARY]Practice TableUSE [Practices]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Practices]([City] [nvarchar] NULL,[PracticeName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[PractitionerName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[Fulltime] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL,[Cost] [float] NULL) ON [PRIMARY] |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-07-24 : 23:49:29
|
| Yes, but what happens if a practitioner moves about? e.g. Dr Bob worked full time for Practice A last year but now works at Practice B. Hence if a cost was incurred last year then you have no way of telling which practice it relates to. |
 |
|
|
mitasid
Yak Posting Veteran
51 Posts |
Posted - 2006-07-27 : 20:15:22
|
| hi Timmy. you are right.If the doctor shifts the practices, we have to calculate the no of days the doctor worked on the old practice and then calculate the cost depending on wheather he was full time or part time and then calculate the cost for the new job |
 |
|
|
|
|
|
|
|