How to make button that increases sequential number by one

Hi,
Although we have the reference number that is generated every time a new record is created,
we also want a separate job number for records that have become definite.

This means certain records will not need this new number job number.
Example:

YG1-No1
YG2
YG3-No2
YG4-No3
YG5
YG6-No4

How would I go about creating this button?
Essentially I want it so that when clicked it searches the database to find the highest number and adds 1 to it.

Hi,

If your logic for job number is very well defined ( not arbitrary ) then you can put one check box.

In before save logic hook as per status of check box, you can make changes as per you requirements.

Regards,

Alpesh Savaliya