Skip to content
Advertisement

Add New Record Value, & Previous Record Value MySQL

I am busy creating a new table in my DB, and have some issues populating the correct values.

The table consists of a number of columns

JavaScript

Using the UPDATE ON DUPLICATE KEY, is not an option here, as I need to keep each and every record, however, adding only the previous value to the new record.

Existing Query:

JavaScript

How do I achieve the above table results? Rather than updating the existing record.

Thanks

Advertisement

Answer

It seems that you need in something like (demo only)

JavaScript

Documentation: Window functions.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement