Jump to content

SELECT LAST(column) AS [expression] MYSQL?


libertyct

Recommended Posts

if you have a clomun of unix dates eg

 

100000001

100000002

100000003

 

it will return 100000003..

 

i guess its similar to MAX()

 

what would be the best way to find a users last transaction from a table using the unix date?

 

table is simple, looks something like this

 

TRANSACTION ID | STUDENTD ID | TRANSACTION DATE | TRANSACTION TYPE

 

now a student might have several different transactions but i only want to retrieve thier most recent transaction, i tried it using the MAX() function but it only returns the last transaction date and not the complete last transaction row

 

my query looks something like this

 

SELECT trans.fldStudentID, prsn.fldFirstName, prsn.fldLastName,

MAX(trans.fldDate) AS fldTransactionDate, trans.fldTransactionCode,

trans.fldCohortID

FROM tblTransaction trans

LEFT JOIN tblStudent stdn ON (trans.fldStudentID = stdn.fldStudentID)

LEFT JOIN tblPerson prsn ON (stdn.fldStudentPersonID = prsn.fldPersonID)

WHERE trans.fldCohortID = 1

GROUP BY trans.fldStudentID

ORDER BY prsn.fldLastName ASC

 

thnx!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.