0
Expensive;
I have a table with several information, among them a field with value_boleto and another with maturity.
It needed first to be ordered the compo due with the current month (current) and after that ordered, add the values of value_boleto.
I tried the query below, but without success:
SELECT * FROM boleto WHERE extract(year_month from vencimento) = 201805, (SUM(-valor_boleto)+5000) AS valor_boleto FROM boleto";
The error generated is syntax from the SUM.
If I only execute the ordering of the current month, it works correctly:
SELECT * FROM boleto WHERE extract(year_month from vencimento) = 201805;
Where I am missing, or rather has a simple frma to make this query?
Friend, despite some errors in your sql, I think I understand what you are wanting. But let’s define a few things first. You need to select all columns of your table or just want the sum of values grouped by period?
– Inácio Régis