Hi allMy SQL skills are fairly basic. Using SQL 2008, although this particular query is in an excel refreshable report. This is what I have so far...select T1.[EQSEQUIPID] as [Equip ID],T1.[Equipment_Status] as [Status],T1.[EQS_Serial_Number] as [Serial No],T2.[EQSEQUIPDESC] as [Description],T2.[Equipment_Branch] as [Branch],isnull(T4.[DSCRIPTN], '') as [Manufacturer],isnull(T5.[DSCRIPTN], '') as [Model],T6.[Acquisition_Cost] as [Acquisition Cost],T6.[ACQDATE] as [Acquisition Date],T7.[NETBOOKVALUE] as [Net Book Value],T8.[ENDDATE] as [Last Hire Date],T8.[CUSTNAME] as [Customer Name] from FPLL..EQSA0000 T1 with (nolock) LEFT JOIN FPLL..EQSA0240 T2 with (nolock) on T2.[EQSEQUIPINDEX] = T1.[EQSEQUIPINDEX] LEFT JOIN FPLL..EQSA0015 T3 with (nolock) on T3.[EQSEQUIPTYPE] = T2.[EQSEQUIPTYPE] LEFT JOIN FPLL..EQSA0035 T4 with (nolock) on T4.[Equipment_Manufacturer] = T2.[Equipment_Manufacturer] LEFT JOIN FPLL..EQSA0005 T5 with (nolock) on T5.[EQSEQUIPMODEL] = T1.[EQSEQUIPMODEL] LEFT JOIN FPLL..FA00100 T6 with (nolock) on T6.[ASSETID] = T1.[EQSEQUIPID]LEFT JOIN FPLL..FA00200 T7 with (nolock) on T7.[ASSETINDEX] = T6.[ASSETINDEX]LEFT JOIN FPLL..EQSV0040 T8 with (nolock)onT8.[EQSEQUIPID] = T1.[EQSEQUIPID] where T1.[Equipment_Status] IN ('AVAILABLE', 'R & M')and T2.[Equipment_Branch] = 'PERTH'and T7.[BOOKINDX] = '1'
So basically table EQSV0040 T8 has multiple lines per EQSEQUIPID. For the 2 fields I'm querying on this table T8.[ENDDATE] as [Last Hire Date],T8.[CUSTNAME] as [Customer Name] I only want the most recent record returned. There is a sequential field in this table DEX_ROW_ID and I have seen a MAX function but can't get the 2 working together.Any help appreciated, thanks.Tania