errorInvalid column name 't0'. Invalid column name 'a0'. Invalid column name 'a0'. Invalid column name 't0'. Invalid column name 'a0'. Invalid column name 'a0'. Invalid column name 't0'. Invalid column name 'a0'. Invalid column name 'a0'. Invalid column name 't0'. Invalid column name 'a0'. Invalid column name 't0'. Invalid column name 'a0'. Invalid column name 'a0'. Invalid column name 'a9999'. (select 'false' as shortlistbasketid,(cast(a1 as decimal) + cast(a2 as decimal) + cast(a3 as decimal) + cast(a4 as decimal) + cast(a5 as decimal) + cast(a6 as decimal) + cast(a7 as decimal)) as custAvailable, [County/Department] as cd,latitude,longitude,isnull(externalimageurl,'/layout/noimg.jpg') as externalimageurl,address1,address2,postcode,description,COUK_BestPrice.provider,a1,a2,a3,a4,a5,a6,a7,COUK_BestPrice.HotelId,establishmentname,town, 0 as proxdistance ,case when ourrank = 0 then 'N/A' else cast(ourrank as varchar(30)) end as vOurRank,t1,t2,t3,t4,t5,t6,t7,cast(t0 as money) as total,(1-(cast(a0 as decimal))) as availorderstr,1 as noofnight,homehyperlinkbo,homehyperlinklr,homehyperlinkhb,homehyperlinkev,bookingcomid,lateroomsid,eviivoid,hostelbookersid,homehyperlink,status,[rooms from] as roomprice,source,(cast(t0 as money))/IIF((1-(cast(a0 as decimal)))<=0,1,(1-(cast(a0 as decimal)))) as pricesort,cast(a9999 as decimal) as availsort,[ourrank] from dbo.#TEMP inner join COUK_BestPrice on #TEMP.[hotel id] = COUK_BestPrice.hotelid and (((cast(t0 as money))/IIF((1-(cast(a0 as decimal)))<=0,1,(1-(cast(a0 as decimal)))) between 0 and 1000) or ((cast(t0 as money))/IIF((1-(cast(a0 as decimal)))<=0,1,(1-(cast(a0 as decimal)))) = 0)) and #TEMP.[hotel id] = 'BNB13752' ) order by proxdistance OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY