 INNER JOIN http_requests T97 ON T290.id = T97.owner_id
 INNER JOIN mobile_enrollments T113 ON T290.id = T113.user_id
 INNER JOIN mru_lists T118 ON T290.id = T118.user_id
-LEFT JOIN next_gen_permissions T120 ON T290.id = T120.grantee_id AND next_gen_permissions.next_gen_permissions.grantee_type = 'User'
+LEFT JOIN next_gen_permissions T120 ON T290.id = T120.grantee_id AND T120.T120.grantee_type = 'User'
 LEFT JOIN permissions_templates T126 ON T290.id = T126.grantee_id AND permissions_templates.grantee_type = 'User'
 INNER JOIN projects T227 ON T290.id = T227.owner_id
 INNER JOIN remote_agents T233 ON T290.id = T233.owner_id

LEFT JOIN extracts T68 ON T301.id = T68.workbook_id
LEFT JOIN hist_workbooks T93 ON T301.id = T93.workbook_id
LEFT JOIN most_recent_refreshes T116 ON T301.id = T116.workbook_id
LEFT JOIN next_gen_permissions T120 ON T301.id = T120.authorizable_id AND next_gen_permissions.authorizable_type = 'Workbook'
INNER JOIN views T297 ON T301.id = T297.workbook_id
INNER JOIN workbook_checksums T299 ON T301.id = T299.workbook_id
INNER JOIN workbook_versions T300 ON T301.id = T300.workbook_id

T120.permission AS "Permission (Next Gen Perm)"
FROM
next_gen_permissions T120
LEFT JOIN workbooks T301 ON T120.authorizable_id = T301.id AND T120.authorizable_type = 'Workbook'
LEFT JOIN projects T227 ON T120.authorizable_id = T227.id AND T120.authorizable_type = 'Project'
LEFT JOIN views T297 ON T120.authorizable_id = T297.id AND T120.authorizable_type = 'View'
LEFT JOIN datasources T55 ON T120.authorizable_id = T55.id AND T120.authorizable_type = 'Datasource'
LEFT JOIN users T290 ON T120.grantee_id = T290.id AND T120.T120.grantee_type = 'User'
LEFT JOIN groups T78 ON T120.grantee_id = T78.id AND T120.T120.grantee_type = 'Group'
INNER JOIN capabilities T30 ON T120.capability_id = T30.id
---------------------------------------------------
-- Table oauth_request_tokens
