Hello Dieter,
I need help in writing an SQL.
I have a Table "A", which has Emplyee ID, Joining Date, Resignation Date. [Resignation Date >= Joining Date].
I have another Table "B", which has the Days which are either Week-ends or, Business Holidays.
I wish to find how many days between Resignation Date & Joining Date is Week-ends/Business Holidays and Working Days for each Employee.
The way, I wrote the SQL:
Select A.Empid, A.Joining_Date, A.Resignation_Date, A.Resignation_Date - A.Joining_Date as "Total Days",
Sum(B.Calendar_Days) as "Non Working Days", "Total Days" - "Non Working Days" as "Working Days"
from A
Join B -- "B" is a Subquery where the Conditions Week-Ends & Business Holidays are Checked.
on B.Calendar_Days between A.Joining_Date + 1 and A.Resignation_Date;
The Problem with above SQL is the Product Join. The Volumne of Data in "A" is huge. The Product Join is rendering the Server very busy and forcing the DBAs to Abort.
Any help or suggestion in witing the above SQL in optimized way is appreciated.
Hello Dieter,
I need help in writing an SQL.
I have a Table "A", which has Emplyee ID, Joining Date, Resignation Date. [Resignation Date >= Joining Date].
I have another Table "B", which has the Days which are either Week-ends or, Business Holidays.
I wish to find how many days between Resignation Date & Joining Date is Week-ends/Business Holidays and Working Days for each Employee.
The way, I wrote the SQL:
Select A.Empid, A.Joining_Date, A.Resignation_Date, A.Resignation_Date - A.Joining_Date as "Total Days",
Sum(B.Calendar_Days) as "Non Working Days", "Total Days" - "Non Working Days" as "Working Days"
from A
Join B -- "B" is a Subquery where the Conditions Week-Ends & Business Holidays are Checked.
on B.Calendar_Days between A.Joining_Date + 1 and A.Resignation_Date;
The Problem with above SQL is the Product Join. The Volumne of Data in "A" is huge. The Product Join is rendering the Server very busy and forcing the DBAs to Abort.
Any help or suggestion in witing the above SQL in optimized way is appreciated.