Avatar of kevin1983
kevin1983
Flag 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]
Microsoft SQL Server 2008Databases

Avatar of undefined
Last Comment
kevin1983

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Horn

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
kevin1983

ASKER
great, Thanks  jimhorn and the recommendation on the address field
Jim Horn

Thanks for the grade.  Good luck with your project.  -Jim
kevin1983

ASKER
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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck