[SQL2005] Variable Table Insert Select
Hi, is it possible to use columns using physical table and variable table under where statement?
Code:
insert into @tb1( local_off_totmins)
select sum(mint_usage)
from tblcalllogs a
where charge_type='local call' and net_type='offnet'
and a.phone_no = tblcalllogs.phone_no
im getting this error
Quote:
Msg 4104, Level 16, State 1, Line 36
The multi-part identifier "tblcalllogs.phone_no" could not be bound.
Re: [SQL2005] Variable Table Insert Select
Don't know if this is the error but You're comparing the field 'phone_no' against itself
'a.phone_no' and table 'tblcalllogs.phone_no' is the same table and the same field
Try next
Code:
Insert Into @tb1( local_off_totmins)
Select Sum(mint_usage)
From tblcalllogs
Where charge_type='local call' and net_type='offnet'