I have a query which gives me some data. I have 12 months say. but it will update the data for the column say month12 (because current month is december)
there are 12 columns based on each month. here is my query,
In my select query I need to find which month's columns needs to be updated.
Below is my query
select --a.emp_mkey,
@Total_day = Sum(total_day),
@Days_worked = Sum(days_worked)
from emp_mon_day a
where a.emp_mkey = @emp_card_no
and a.month = @actualMonth and Year = @actualYear
group by emp_mkey
if(@Days_worked > 0)
BEGIN
set @actualleavedays =((1.75) / @Total_day) * (@Days_worked)
END
print @actualleavedays
I am using SQL - server 2005
UPDATE
so what month will come here -- month1, month2, ...... ???
-- update p_leave_allocation_14122015 a
-- set a.month1 = 8.18
-- where year = a.actualYear and a.emp_card_no = @emp_card_no
Do let me know if you want to view whole procedure.
Aucun commentaire:
Enregistrer un commentaire