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:)
drhoffman
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
select
  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')
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered



Return to SQL

Who is online

Users browsing this forum: No registered users and 2 guests