Ok, so here is example code for view. Second part with select RT.RoleID[...] seems clear to me. That's the part that's going to be displayed when the query will be run to use the view. first part is unclear though. 
First two lines are standard as i understand, then goes the whole with section. Could someone explain it to me? Never seen with "something" as (select) formula
    CREATE VIEW [dbo].[sviw_System_MyPermissions_CurrentDomain]
AS  
WITH MyDomainRoles AS (
  SELECT RM.Domain, RM.RoleID
    FROM stbl_System_RolesMembersDomains AS RM WITH (NOLOCK)
    WHERE RM.Domain = (SELECT CurrentDomain FROM stbl_System_Users WITH (NOLOCK) WHERE Login = SUSER_SNAME())
      AND RM.Login = SUSER_SNAME()
)
SELECT RT.RoleID, RT.TableName, DR.Domain, RT.GrantUpdate, RT.GrantInsert, RT.GrantDelete
  FROM stbl_System_RolesTables AS RT WITH (NOLOCK) 
    JOIN MyDomainRoles AS DR ON RT.RoleID = DR.RoleID
GO
 
     
    