0

我有两个表(serverlogdetail a,serverlogid b),用于跟踪用户活动用户可以在一天内多次登录不同的应用程序(a.entrydate)到不同的应用程序(b.appname)对于用户拥有的所有应用程序访问 我需要返回他/她最后一次登录的列表。

SELECT  b.appname ,max(to_char(a.entrydate)),  a.username,  a.msgnumber
  FROM serverlogdetail a, serverlogid b

  WHERE a.msgnumber = 1020055 
  AND A.entrydate BETWEEN (SYSDATE-90) AND SYSDATE

GROUP BY b.appname, a.dbname, a.username,a.msgnumber, a.entrydate
ORDER BY b.appname, max(to_char(a.entrydate))

提前致谢

4

1 回答 1

0
SELECT  b.appname , a.username,  a.msgnumber, max(to_char(a.entrydate))
FROM serverlogdetail a, serverlogid b

WHERE a.msgnumber = 1020055 
AND A.entrydate BETWEEN (SYSDATE-90) AND SYSDATE
AND A.something = B.something           -- the condition you're missing!!!

GROUP BY b.appname, a.username, a.msgnumber
ORDER BY b.appname, max(to_char(a.entrydate))
于 2012-07-10T23:21:38.440 回答