-2

I'm not sure how to create an sql procedure to get a JobID as LastJobID where the ID is the max.

My procedure looks like this as of right now : `SELECT MAX( ID ) as LastJobID FROM jobs;`

But I need something like this: `SELECT JobID as LastJobID FROM jobs where MAX( ID );`

The latter gives me an error.

My table consists of a unique auto incremented ID, JobID and other attributes as well. I just need to get the JobID from the Max( ID ) because the JobID's are Alpha numeric so getting the MAX( JobID ) won't get me correct results.

Sorry if this is hard to understand, but if anyone has an idea of a procedure that would let me do this, I would greatly appreciate it!

Michael
  • 1,454
  • 3
  • 19
  • 45

1 Answers1

0

Try this

  SELECT JobID as LastJobID FROM 
  jobs 
  where id =
  ( select MAX( ID ) from jobs) 
Himanshu
  • 3,830
  • 2
  • 10
  • 29