-1
Try using the following code:
SELECT
SUM(d1 + d2 + d3 + ... + d12) as soma
FROM
janeiro
-1
4
Try using the following code:
SELECT
SUM(d1 + d2 + d3 + ... + d12) as soma
FROM
janeiro
2
Your model is bad make one of the kind
Date Valor
With date functions it becomes easy to total by month , year, week etc.
Browser other questions tagged mysql sql
You are not signed in. Login or sign up in order to post.
Dan, I thought about doing this, but there will be 12 tables (one for each month), I wanted to know if I would have a better sql. And how would group the plans of accounts?
– alessandre martins
Unfortunately the way you modeled the bank may be the only way (in my logic), to group by plane, you must perform a select by pulling the plane and performing a group by. It would be more interesting to create a single table, containing the columns: id, value, month. There you have only one table, it would be the most correct form in this example.
– Dan Lucio Prada
Bad models generate bad and unnecessarily complicated sqls.
– Motta