TSQL to get a list of all users and when they last logged on in crowddb
You have an extra SELECT in your SQL.

Remove the SELECT and change the DATEADD function slightly.

SELECT 
  cwd_user.user_name, 
  DATEADD(SECOND,(CAST(cwd_user_attribute.attribute_value AS BIGINT)/1000),'1970-01-01')
FROM cwd_user, cwd_user_attribute 
WHERE cwd_user_attribute.user_id = cwd_user.id 
  AND cwd_user_attribute.attribute_name = 'lastAuthenticated';


Additionally, you should probably rewrite to support the 'new' JOIN syntax (by 'new', I mean ANSI-92)

SELECT 
  cwd_user.user_name, 
  DATEADD(SECOND,(CAST(cwd_user_attribute.attribute_value AS BIGINT)/1000),'1970-01-01')
FROM cwd_user
INNER JOIN cwd_user_attribute 
   ON cwd_user_attribute.user_id = cwd_user.id 
  AND cwd_user_attribute.attribute_name = 'lastAuthenticated';