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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.