I'm using PostgreSQL. I have a reading value in my table. From that, I have to find the consumption by subtracting previous value.
I found the SQL query. How to use that in sequelize? Is there any other option except raw queries?
SQL Query:
SELECT "readingValue",
"readingValue" - COALESCE(LAG("readingValue") OVER
(ORDER BY "readingTime")) AS consumption
FROM public."tableName" LIMIT 100;