2
I have a table, where I am bringing two different results with the query below:
select sum(qtde_pontos) from dbo.tbl_cc_ponto where re = '9289'
and natureza_operacao = '2'
and data_lacto >= '2012-01-01'
and data_lacto <= '2017-08-10'
union
select sum(qtde_pontos) from dbo.tbl_cc_ponto where re = '9289'
and natureza_operacao = '1'
and data_lacto >= '2012-01-01'
and data_lacto <= '2017-08-10'
The output is as follows::
480.00
545.00
In case, I would like to subtract the value 545.00 less the 480.00 and the result thereof (65.00), compare with another table I have called: cc_point comparing to the column current point. And this way bringing me if the result (65.00) is different or not from the column "ponto_saldo_actual".
It is possible to do this?
Thanks in advance.
If you are using only Sqlserver or have a language in the middle of it all, or you want to create a Storedprocedure and do this, the options are several, as will compare with the other table?
– novic
At first I would just like to do this in SQL to see the result. Later, I would take it to PHP. But first I wanted to know if it’s possible in SQL. On the comparison, my question is two: bring the result of the two select and compare this value with another table.
– user2287892
With storedprocedure I believe it solves
– novic
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack