I have the following query:
SELECT finempe.data_empenho
, finempe.num_empenho
, finhisem.quantidade
, finhisem.historico
, finhisem.valor
, finhisem.valor_total
FROM finempe
RIGHT JOIN finhisem ON
(finhisem.num_empenho = finempe.num_empenho)
WHERE finempe.data_empenho between '01-01-2002' and '31-12-2002' and finempe.valor_empenhado != finempe.valor_anulado and finempe.codigo_tipo = 1 and finhisem.codigo_tipo = 1 and conta_desp = 31900100 and finhisem.ano_empenho = 2002
ORDER BY finempe.num_empenho, finhisem.num_seq
I want to group the rows, but concatenating the historical field (I imagine doing a SUM in value and total-value and concatenation in < in> historical )
Examplegroupingline5,6and7:
"2002-01-02" "45" "10000" "Provision of resources for the complementary payment to retired employees linked to FUNCAPI, for the period from January to December 2002" "540000" "540000"
ie keep all values and concatenate history