Hi friends,
How can i write if else condition for bewlow queries. I wrote like as below but, i am getting errors.
if(r.version >1)
begin
select b.bidid, r.BidrefName,b.StartDate,b.EndDate, r.version from dbo.tblBid b inner join dbo.tblBidref r on b.BidID= r.BidID
where DealID=89914275 and Version=2
end
else
begin
select b.bidid, b.Description, b.StartDate,b.EndDate,r.version from dbo.tblBid b inner join dbo.tblBidref r on b.BidID= r.BidID
where DealID=89914275 and Version=1
end
error:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "r.version" could not be bound.
...
Go to the complete details ...