CONCAT not working

Asked

Viewed 67 times

1

SELECT 
indicativo_ja_registrado,  
qra,
fez_contato, 
DATE_FORMAT(data_qso, '%d/%m/%y') AS data_qso, 
DATE_FORMAT(data_agora, '%d/%m/%Y') AS data_agora,
TIMESTAMPDIFF(YEAR, data_qso, data_agora) AS Anos,
TIMESTAMPDIFF(MONTH, data_qso + INTERVAL TIMESTAMPDIFF(YEAR, data_qso, data_agora) YEAR , data_agora) AS Mes,
TIMESTAMPDIFF(DAY, data_qso + INTERVAL TIMESTAMPDIFF(MONTH, data_qso, data_agora) MONTH , data_agora) AS Dias,
    Anos,
    Mes,
    Dias,
    CONCAT(Anos, ' Anos ', Mes, ' Mes e ', Dias, ' Dias') AS Extenso        
    quantidade_dias, 
hora_qso, 
faixa_simplex_MHz, 
faixa_MHz_qso_trans_repetidora, 
faixa_MHz_qso_trans_outras, 
nome_pais  
FROM qry_pesquisa_dois 
ORDER BY qry_pesquisa_dois.data_qso DESC; 

The TIMESTAMPDIFF of the 'Years', 'Mes' and "Days' have satisfactory results, but CONCAT does not work.

  • makes a mistake???

  • Was the answer helpful? Don’t forget to mark to accept it. So you can use it if someone has a similar question!

1 answer

1

Try it like this:

SELECT *, CONCAT(Anos, ' Anos ', Mes, ' Mes e ', Dias, ' Dias') AS Extenso FROM (       
SELECT 
    indicativo_ja_registrado,  
    qra,
    fez_contato, 
    DATE_FORMAT(data_qso, '%d/%m/%y') AS data_qso, 
    DATE_FORMAT(data_agora, '%d/%m/%Y') AS data_agora,
    TIMESTAMPDIFF(YEAR, data_qso, data_agora) AS Anos,
    TIMESTAMPDIFF(MONTH, data_qso + INTERVAL TIMESTAMPDIFF(YEAR, data_qso, data_agora) YEAR , data_agora) AS Mes,
    TIMESTAMPDIFF(DAY, data_qso + INTERVAL TIMESTAMPDIFF(MONTH, data_qso, data_agora) MONTH , data_agora) AS Dias,    
    quantidade_dias, 
    hora_qso, 
    faixa_simplex_MHz, 
    faixa_MHz_qso_trans_repetidora, 
    faixa_MHz_qso_trans_outras, 
    nome_pais  
FROM qry_pesquisa_dois 
ORDER BY qry_pesquisa_dois.data_qso DESC ) t;
  • Virgilio, gives some error???? Resp: Just didn’t give the CONCAT result. Your suggestion worked correctly. Thanks

  • If the answer helped you can accept as an answer to your question!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.