I have a table with date ranges and another with sales data. How can I mount a query that brings me the sales totals in the last 3 periods from the datas_periodos
??
Tabela (datas_periodos): id_datas; data1; data2;
id_datas; data1; data2;
192 2014-01-04 2014-02-01
193 2014-02-02 2014-03-01
Tabela (vendas): id_vendas; data_venda; vendedor; valor_vendas;
id_vendas; data_venda; vendedor; valor_vendas;
1953 2014-01-02 maria 30000,00
3444 2014-01-02 joao 15000,00
3212 2014-02-03 antonio 34202,00
I would need an output like this:
data1 data2 valor total
2014-01-04 2014-02-01 150000,00
2014-02-02 2014-03-01 300000,00
Thanks for the help.