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 |
|
vinaym
Starting Member
8 Posts |
Posted - 2011-05-27 : 05:30:08
|
I have Employee Salary table as following with dataEmployeeSalaryID EmployeeId StartDate Sallary1 25 2011-03-01 100002 18 2011-03-01 50003 31 2011-03-01 12504 25 2011-04-01 150005 18 2011-04-01 75006 31 2011-04-01 2500I have work Table as following with data (not all fields)WorkID WorkId StartDate EndDate1 25 2011-03-01 2011-06-012 18 2011-03-01 2011-06-013 31 2011-03-01 2011-07-014 25 2011-05-01 2011-08-015 18 2011-05-01 2011-09-016 31 2011-05-01 2011-06-01one more table as a transaction of work as following with dataID Employee_ID TransactionDate Duration Work_IDLogsheet2 18 2011-03-29 10 23 18 2011-03-29 10 24 25 2011-03-29 10 45 25 2011-03-29 10 16 25 2011-03-29 5 37 25 2011-03-29 5 28 31 2011-04-25 10 410 31 2011-04-26 30 414 31 2011-04-26 45 315 31 2011-04-26 30 516 18 2011-04-27 20 518 18 2011-04-27 70 519 18 2011-04-27 13 121 18 2011-05-21 10 1Now I want costing of my work.Condition: Transaction date and salary date connection.... e.g for transaction date 2011-03-29 and employee id 18 then salary should be consider 10000 and for same employee transaction date 22011-04-27 salary should be consider 15000. Now I want four combinational types of out-put from these...1) WorkID wise costing (Total)2) WorkID wise costing (EmployeeID Wise)3) EmployeeID wise costing (Date Wise)4) EmployeeID wise costing (WorkID Wise)I have all of them out-put but I'm not able to follow my Condition.I have written following querySELECT Logsheet.Employee_ID, SUM(Logsheet.Duration) AS Duration, SUM(Logsheet.Duration) * (EmployeeSalary.Sallary / 10500) AS CostingFROM Logsheet INNER JOIN Work ON Logsheet.Work_ID = Work.ID INNER JOIN EmployeeSalary ON Logsheet.Employee_ID = EmployeeSalary.EmployeeIdWHERE (Job_Activity.Job_ID = 1)GROUP BY Logsheet.Employee_IDSo please guide me in my query |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2011-05-27 : 05:55:23
|
| Could not understand logic of calculation.why 10500 is hardcoded in your query ?Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
vinaym
Starting Member
8 Posts |
Posted - 2011-05-27 : 06:27:53
|
| Sorry I forgot to mention that Duration in Logsheet is in minute thats why I have use standard working duration in minute for a month as 10500. |
 |
|
|
vinaym
Starting Member
8 Posts |
Posted - 2011-05-31 : 03:30:44
|
| Please reply this post with answer.... |
 |
|
|
|
|
|