Answer the question
In order to leave comments, you need to log in
How to correctly do subtraction in SELECT PostgreSQL?
There is such a crm_reffin table :
id | play date | totalsum | refid |
---|---|---|---|
one | 2016-02-27 18:47:29.850391 | ten | eighteen |
2 | 2016-02-27 18:47:43.309427 | 20 | eighteen |
3 | 2016-02-27 21:36:19.088732 | 100 | eighteen |
SELECT playdate, totals as credit, (SELECT sum(debate) * 0.1 FROM log WHERE uid IN (SELECT id FROM users WHERE refid = (SELECT id FROM crm_referals WHERE uid = :uid))) AS sumdebet FROM crm_reffin WHERE refid = (SELECT id FROM crm_referals WHERE uid = :uid);
pay date | credit | sumdebet |
---|---|---|
2016-02-27 18:47:29.850391 | ten | 8451 |
2016-02-27 18:47:43.309427 | 20 | 8451 |
2016-02-27 21:36:19.088732 | 100 | 8451 |
pay date | credit | sumdebet |
---|---|---|
2016-02-27 18:47:29.850391 | ten | 8451 |
2016-02-27 18:47:43.309427 | 20 | 8441 |
2016-02-27 21:36:19.088732 | 100 | 8421 |
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question