Link to home
Start Free TrialLog in
Avatar of kevin1983
kevin1983Flag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL select code to show records with highest Delivery number

Hi,
I have the below basic sql select code but id like to only display the highest DeliveryNum records related to the the DocNum in the results. Ie only the DocNum line with the highest DeliveryNum number record shown

For example at the moment the results show 2 records both with Docnum 46182 and one record with DeliveryNum 2309 and the other record with 2320, but id like the results to only show one line with the delivery number: 2320

Is this possible?


SELECT [TrgetEntry]
      ,[DocEntry]
      ,[DocNum]
      ,[NumAtCard]
      ,[DeliveryNum]
      ,[CardCode]
      ,[ShipToCode]
      ,[Address]
      ,[SalesDocDelivery]
  FROM [LiveDB].[dbo].[View_Driver]
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevin1983

ASKER

great, Thanks  jimhorn and the recommendation on the address field
Thanks for the grade.  Good luck with your project.  -Jim
Thanks, I had a little search on-line for reserved t-sql keywords but couldn't see address listed unless the lists I found were not up to date and address is a more recent word?.

http://msdn.microsoft.com/en-us/library/ms189822.aspx