SQL Max vs Latest Record


I have a SQL query where I want to show information in the last record entered on a field called [Machine number] rather than just the Maximum.
Is this possible?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
John TsioumprisConnect With a Mentor Software & Systems EngineerCommented:
You need some kind of indication that marks the latest entry per machine ...either a timestamp or a sequential recordID....from there you take the max of them to get the associated latest entry...
Pawan KumarConnect With a Mentor Database ExpertCommented:
Do u have a date column like when the record is inserted?

Or do you know how that record is the latest one.
Pawan KumarDatabase ExpertCommented:
If yes you have a date or some id column you can use below to get the Latest Machine Number row. You can replace the * with the column names you want.

FROM yourtableName
ORDER BY dateColumn DESC


FROM yourtableName
ORDER BY IdColumn DESC /*Some Integer primary Key*/
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thank you. There is a Date column, which I will use. I appreciate the advice from both of you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.