Select last DB entry

From the following query, what do I need to add to be able to select the last row only.

Can either be the index number or t_stamp.

SELECT ACC_2_Piston_Pressure, Back_Pressure_SP, Back_Pressure_Time, Charged_Volume, Chill_Timer, Extruder_Pressure, Extruder_Temperature, Joint_Cast_Date_Time, Joint_Volume_Used, Lock_Bar_Pressure, Mould_Fill_Time, Purged_Volume, Total_Joint_Time, t_stamp, Joint_Number, Total_Joint_Timer, Mould_Fill_Timer FROM impp_logs ORDER BY t_stamp DESC

This is so my report viewer only shows the latest row in the table.

SELECT top 1 ACC_2_Piston_Pressure, Back_Pressure_SP, Back_Pressure_Time, Charged_Volume, Chill_Timer, Extruder_Pressure, Extruder_Temperature, Joint_Cast_Date_Time, Joint_Volume_Used, Lock_Bar_Pressure, Mould_Fill_Time, Purged_Volume, Total_Joint_Time, t_stamp, Joint_Number, Total_Joint_Timer, Mould_Fill_Timer
FROM impp_logs
ORDER BY t_stamp DESC

Error running query: SQLQuery(query=SELECT top 1 ACC_2_Piston_Pressure, Back_Pressure_SP, Back_Pressure_Time, Charged_Volume, Chill_Timer, Extruder_Pressure, Extruder_Temperature, Joint_Cast_Date_Time, Joint_Volume_Used, Lock_Bar_Pressure, Mould_Fill_Time, Purged_Volume, Total_Joint_Time, t_stamp, Joint_Number, Total_Joint_Timer, Mould_Fill_Timer FROM impp_logs ORDER BY t_stamp DESC, database=mobile)@5000ms On: Logging PDF.Root Container.Report Viewer.IMPP

You didn’t say what database you are using. It is different if you are using MySQL or SQL Server.

Try this for MySQL:

SELECT ACC_2_Piston_Pressure, Back_Pressure_SP, Back_Pressure_Time, Charged_Volume, Chill_Timer, Extruder_Pressure, Extruder_Temperature, Joint_Cast_Date_Time, Joint_Volume_Used, Lock_Bar_Pressure, Mould_Fill_Time, Purged_Volume, Total_Joint_Time, t_stamp, Joint_Number, Total_Joint_Timer, Mould_Fill_Timer
FROM impp_logs
ORDER BY t_stamp DESC
LIMIT 1

A apologies folks, I never knew the code would be different for different databases.

When I was goggling I was searching “SQL last DB entry”. No wonder I was scratching my head for so long as I am indeed using MySQL

Thanks :thumb_left: :thumb_left:

No problem. Totally understandable. :thumb_left: