text: 
  
  CREATE OR REPLACE VIEW SURVEY.VW_AGENT AS 
  
  WITH AGENTS AS (
  SELECT DISTINCT
  	"EMAIL",
  	"NAMEOFAGENT"  AS "NAME",
       DATEFROMPARTS(uniform(2000, 2020, random()),uniform(1, 12, random()),uniform(1, 25, random())) AS STARTED_DATE
     
  FROM "SURVEY"."STG_DATA" 
  //WHERE
  //	NAMEOFAGENT = 'Agent39'
  )
  
  SELECT 
    EMAIL,
    NAME,
    STARTED_DATE  
  FROM
  (
  SELECT * , ROW_NUMBER() OVER (PARTITION BY NAME ORDER BY STARTED_DATE DESC) AS LATEST
  FROM AGENTS
  )
  WHERE
      LATEST = 1;
  
  GRANT DELETE ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT INSERT ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT REFERENCES ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT REBUILD ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT UPDATE ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT SELECT ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  GRANT TRUNCATE ON TABLE SURVEY.VW_AGENT TO ROLE SYSADMIN;
  