表格1:
ResourceID
Name0 (STRING)
NumberOfLongons0 (INT)
LastLogon0 (DateTIME)
表2:
ResourceID
NetbiosName0
我正在尝试检索以下数据:
NetbiosName0
, Name0
, NumberOfLogons0
,LastLogon0
它向我显示的位置NetbiosName0
,无论是否存在其他数据,并且Name0
/LastLogon0
哪里NumberOfLogons0
是最高的ResourceID
更新:
测试了SQL:
SELECT T2.ResourceID, T2.Netbios_Name0, T1.Name0, T1.NumberOfLogons0, t1.LastLogon0
FROM V_R_System T2 LEFT OUTER JOIN v_GS_NETWORK_LOGIN_PROFILE T1
ON T2.ResourceID = T1.ResourceID
WHERE NOT EXISTS
(SELECT * FROM v_GS_NETWORK_LOGIN_PROFILE
WHERE ResourceID = T2.ResourceID AND NumberOfLogons0 > T1.NumberOfLogons0)
并得到以下结果:
8435 CLETESTXP-001 NT AUTHORITY\LOCAL SERVICE
8435 CLETESTXP-001 NT AUTHORITY\NETWORK SERVICE
8435 CLETESTXP-001 NT AUTHORITY\SYSTEM
8435 CLETESTXP-001 TESTAGNA\JBradnan 109 3/22/2012 11:37:00 AM