I got totally stuck on comparing two tables and getting the difference between them
So here we go: I got table a with the following columns Name|Value|Date
and the second table b with the same columns
What i wanna do now is get the difference between the values like
Table a
Name|Value|Date
Test|3|2013-20-06
Table b
Name|Value|Date
Test|9|2013-20-06
What i wann get is the difference between the 3 and 9 so i would recieve 6
Any Idea how i'm able to get that from a query in my PostgreSQL-DB?
When the difference between two values is divided by the average of the same values, a percentage difference calculation has occurred. The formula for percentage difference looks like this: Percentage difference = Absolute difference / Average x 100.
Percentage Difference Formula The percentage difference between two values is calculated by dividing the absolute value of the difference between two numbers by the average of those two numbers. Multiplying the result by 100 will yield the solution in percent, rather than decimal form.
Given two numerical quantities, x and y, their difference, Δ = x − y, can be called their actual difference. When y is a reference value (a theoretical/actual/correct/accepted/optimal/starting, etc. value; the value that x is being compared to) then Δ is called their actual change.
Join the tables and select the difference:
select a.name, b.value - a.value, a.date
from a inner join b on a.name = b.name and a.date = b.date
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With