I want to fetch data for a perticular product on basis of last user & respective last used time.Example
Host Product LastUserName LastUsedTime
1 X1 ABC 6/13/2014
1 X1 ABC 6/14/2014
1 X1 ABC 6/15/2014
1 X1 XYZ 6/14/2014
1 X1 XYZ 6/15/2014
1 X1 XYZ 6/16/2014
I have tried MAX function and find data as
Host Product LastUserName LastUsedTime
1 X1 ABC 6/15/2014
1 X1 XYZ 6/16/2014
But unable to get desired output which is
Host Product LastUserName LastUsedTime
1 X1 XYZ 6/16/2014
SQL:
select a.Netbios_Name0, b.DisplayName0, c.LastUserName0,
MAX(c.LastUsedTime0) as [Last Used Time]
from table1 a,table2 b,table3 c
where a.ItemKey = b.ResourceID
and a.ItemKey = c.ResourceID
group by a.Netbios_Name0, b.DisplayName0, c.LastUserName0
order by b.DisplayName0
Thanks for Help !!