Answer the question
In order to leave comments, you need to log in
How to get the difference between the values of a column when querying for a time period?
I collect information about applications. According to the report - for the day. I can get the number of installs for the lifetime of the app, while the rest of the data is broken down by day.
The task - I want to calculate the difference between the day of the request - and the previous day, having the total number of installations, inside the request for all data on the application for the period.
SELECT "vr"."installs" as "installs" -(SELECT "vr"."installs" FROM "vungle_raport" "vr" WHERE "vr"."date" BETWEEN DATE '2017-02-28' - '-1 day' AND BETWEEN DATE '2017-02-30' - '-1 day')
FROM "app" "vr"
WHERE "vr"."date" BETWEEN '2017-02-28' AND '2017-03-30'
Answer the question
In order to leave comments, you need to log in
Make a LEFT JOIN and filter out the results by NULL where no matches were found.
I didn't quite understand what exactly needs to be done. But, I think, you need to look towards WINDOW FUNCTIONS.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question