Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Subtraction from obtained results using sql

date follwer
23-10-2022 1
22-10-2022 0
21-10-2022 1
20-10-2022 2

Total followers 250

Expected output:

date follwer
23-10-2022 251
22-10-2022 250
21-10-2022 249
20-10-2022 247

I want to implement above result using sql can one one suggest me some solution

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your output could be generated by this query:

SELECT date, 251 - SUM(follwer) OVER (ORDER BY date DESC) + follwer AS follwer
FROM yourTabld
ORDER BY date DESC;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading