|
SELECT DISTINCT '' as License,Firm.ID as Value,Firm.Phone,Firm.Fax,isnull(Firm.Email,'')as email,Firm.WWW,isnull(Firm.WorkTime,'') as wt,Firm.Comment,COMMON.dbo.fFirmAdres(Firm.ID,2) as Adres,Firm.Name,Firm.NameShort, case when ReclName is null then NameShort else ReclName end as Text,Firm.NameFull,FirmPublicity.ID,FirmPublicity.FirmID as PID,isnull(FirmPublicity.Logo,'') as logo,FirmPublicity.URL,cast(AdvAddress as varchar(1000)) as AdvAddress FROM Firm as Firm LEFT JOIN FirmPublicity ON Firm.ID = FirmPublicity.FirmID left outer join common.dbo.FirmAddFields faf on firm.ID = faf.FirmID LEFT JOIN Appartment ON Firm.ID = Appartment.SellerID LEFT JOIN AppartmentPublicity ON Firm.ID = AppartmentPublicity.SellerID and getdate() between AppartmentPublicity.datefrom and AppartmentPublicity.dateto LEFT JOIN House ON Firm.ID = House.BuilderID WHERE (IsNull(Appartment.ID,0)>0 OR IsNull(AppartmentPublicity.ID,0)>0 OR IsNull(House.ID,0)>0) and substring(firm.nameshort,1,1) between 'Ф' and 'Я' and org_typ like '%Realtor;%' ORDER BY Firm.NameShort
|
|