I need to make a list about the company's billing.

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc

Poston Wed, 17 May 2006 11:43 pm

Good guys, I'm new to andancas and I'm still learning! my doubt is as follows I have an invoice table (id_factura, valor_total, data_pagamento) I need to know how do I know the amount invoiced per month during the last 12 months, IE have QO obtain 12 rows, and in each I have q have the invoiced value (per month) by the company.

someone can help me? obrigadao:)
Location: LISBOA

Poston Mon, 05 Jun 2006 12:35 pm

You need to do a SUM grouped by DATE.
Something like this:
Code: Select all
  trunc(data_pagamento, 'mm') data
, sum( valor_total ) soma
from facturas
where data_pagamento >= add_months(trunc(sysdate,'mm'), -12)
group by
  trunc(data_pagamento, 'mm')
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?

Return to SQL

Who is online

Users browsing this forum: Google [Bot] and 10 guests