SQL Server – How can I enter an If if it exists in a SQL Select?

I want to know in the right way whether a project exists in a query, based on that result, whether actions should be applied and whether no other new actions are being applied.

SQL code:

SELECT NEWID (), r.Project, r.Import, r.ClassCosy, r.CutSelect, r.NumHours, r.Provider,
r.TypeService, r.FolioSantec, r.Ambiente, r.Tecnologia, case, if r.Ambiente = & # 39; PRE & # 39 ;, then r.NumHoras * m.TarifaOLC, else

IF EXISTS (SELECT * FROM db_Incurrido.dbo.GSE_Real gse WHERE gse.Proyecto = r.proyecto)
BEGINNING
SELECT 1
THE END
ELSE
BEGINNING
SELECT 2
THE END

End of imports OLC
FROM db_Incurrido.dbo.GSE_Real r (nolock)
left outer join db_Incurrido.dbo.FYCG_Migracion_TarifaMedia m (nolock) on r.FolioSantec = m.Proyecto;