1
I have a table with date ranges and another with sales data. How can I assemble a query that brings me the sales totals in the last 3 periods from the table 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’d need an exit like this:
data1 data2 valor total
2014-01-04 2014-02-01 150000,00
2014-02-02 2014-03-01 300000,00
Grateful for the help.
Have you ever tried anything,
select * from tabela
. If yes, edit your question so we can better help you.– Marcelo Diniz