doubts with select sum () Mysql

-1

I have these two tables, January and February:

Eachfieldcorrespondstothedayofthemonth,d1=day01,etc.Ineedtocreateaselectthatshowsthemonthlyvalueofeachaccountplan,forexample:

How would this sql be?

    
asked by anonymous 18.03.2017 / 21:52

2 answers

2

Your model is bad, make one of the

Table

Date Value

With date functions makes it easy to total by month , year, week etc.

    
18.03.2017 / 22:13
4

Try to use the following code:

SELECT
  SUM(d1 + d2 + d3 + ... + d12) as soma
FROM
  janeiro
    
18.03.2017 / 22:03