0
I have the following variables::
$v_data = $row['DATA'];
$v_filial = $row['FILIAL'];
$v_chapa = $row['CHAPA'];
$v_func = $row['FUNCIONARIO'];
$v_dias = $row['DIAS'];
$v_desc = $row['DESCRICAO'];
They bring this:
DATA FILIAL CHAPA FUNCIONARIO DIAS DESCRICAO
10-04-2016 2 2311 JOAO DE SOUZA 7 TESTE
24-04-2016 2 2311 JOAO DE SOUZA 14 TESTE
08-05-2016 2 2311 JOAO DE SOUZA 14 TESTE
15-05-2016 2 2311 JOAO DE SOUZA 7 TESTE
05-06-2016 2 2311 JOAO DE SOUZA 21 TESTE
12-06-2016 2 2311 JOAO DE SOUZA 7 TESTE
What do I need: Where the dates are equal add the days column and if possible change the date column, example:
DATA FILIAL CHAPA FUNCIONARIO DIAS DESCRICAO
10-04-2016 2 2311 JOAO DE SOUZA 7 TESTE
24-04-2016 2 2311 JOAO DE SOUZA 14 TESTE
Expected result:
DATA FILIAL CHAPA FUNCIONARIO DIAS DESCRICAO
04 2 2311 JOAO DE SOUZA 21 TESTE
@Marllon Nasser, follow query:
SELECT
ifd_filial AS FILIAL,
ifd_chapa AS CHAPA,
ifd_nome AS NOME,
DATE_FORMAT(ifd_dataa,'%m') AS MÊS,
SUM(ifd_dias) AS DIAS,
ifd_desc AS DESCRICAO
FROM
imp_folga_domingo
WHERE ifd_chapa = 2311
GROUP BY ifd_dataa;
which bank? oracle?
– Marllon Nasser
Database: SQL SERVER .
– Chefe Druida
Well, you have to make one
group by
for the month of the date... and make a sum ofDIAS
. That’s what you need to do.. I recommend doing it by query.. for php unfortunately I don’t know how to do it. But the solution is this.– Marllon Nasser
@Marllonnasser brought to MYSQL I made the query no longer adding,could check if my syntax is correct ? I added the same question .
– Chefe Druida
@otaciojb sum if the dates are equal or if the month of the date is equal?
– novic
@Virgilionovic Month
– Chefe Druida
I saw what was wrong with @Virgil’s question.
– Chefe Druida
@otaciojb Missed the
group by
on date...GROUP BY DATE_FORMAT(ifd_dataa,'%m');
– Marllon Nasser
@Marllonnasbe that way, vlw..
– Chefe Druida
Got it !!! you want a solution
SQL
that @Marllonnasser seems to have solved, or you want a solutionPHP
???– novic
@Virgilionovic for me PHP would be better,more as I need to release I did with your help in sql even.
– Chefe Druida