create proc bai5_3
as
declare @m int, @d int;
set @m = MONTH(ThuNhap_AnNV.NgayLap_3974);
declare @tmp int;
set @tmp = DAY(ThuNhap_AnNV.NgayLap_3974);
set @d = 0;
if(@m = 4 or @m = 6 or @m = 9 or @m = 11)
begin
set @d = @d + 30 - @tmp;
end
if(@m = 1 or @m = 3 or @m = 5 or @m = 7 or @m = 8 or @m = 10 or @m = 12)
begin
set @d = @d + 31 - @tmp;
end
if(@m = 2)
begin
set @d = @d + 28 - @tmp;
end
set @m = @m + 1;
while(@m <= 12)
begin
if(@m = 4 or @m = 6 or @m = 9 or @m = 11)
set @d = @d + 30;
if(@m = 1 or @m = 3 or @m = 5 or @m = 7 or @m = 8 or @m = 10 or @m = 12)
set @d = @d + 31;
if(@m = 2)
set @d = @d + 28;
set @m = @m + 1;
end
select cb.MaCB_3974, cb.HoTenCB_3974, count(bl.GioQuyDoi) [Tổng giờ quy đổi], (cb.HSNV_3974*dv.Tdv_3974*@d) [Tổng tiền lương năm 2021]
from CanBo_AnNV cb, ChiTietThuNhap_AnNV bl, DonVi_AnNV dv, ThuNhap_AnNV tn
where cb.NhiemVu_3974 like N'Trưởng%' and cb.MaCB_3974 = bl.MaCB_3974 and bl.MaTN_3974 = tn.MaTN_3974
and tn.MaDV_3974 = dv.MaDV_3974
group by cb.MaCB_3974 , cb.HoTenCB_3974, cb.HSNV_3974, dv.Tdv_3974
it said The multi-part identifier "ThuNhap_AnNV.NgayLap_3974" could not be bound.
i had tried the join
statement but it still didn't work.
im running sql query on mySQL server