You can use a variable in the query. The value for the variable can for example come from a parameter if this is a stored procedure. See
DECLARE @local_variable (Transact-SQL) - SQL Server | Microsoft Docs[
^]
As an example, consider the following excerpt
declare @groupid int;
set @groupid = 1;
select r1.familyid, r1.companyid,
...
where r1.GroupID = @groupid