If you want to obtain as separate data:
SELECT COUNT(tipo) as quantidade,
identificador,
GROUP_CONCAT(de ORDER BY de SEPARATOR ', ') AS dados
FROM tabela
GROUP BY tipo,
identificador
Or if you want to get it now with the proposed text:
SELECT CONCAT(COUNT(tipo), ' dados de ', GROUP_CONCAT(de ORDER BY de SEPARATOR ', '), ' sobre o identificador ', identificador) AS texto
FROM tabela
GROUP BY tipo,
identificador
Where:
COUNT account for the occurrences of a line based on the grouping function (GROUP BY);
CONCAT concatenates the fields listed (includes the text between ');
GROUP_CONCAT concatenates the columns lists based on the grouping function.
COUNT
Returns a Count of the number of non-NULL values of expr in the Rows retrieved by a SELECT statement. The result is a BIGINT value.
In free translation:
Returns the numerical count of non-NON-NORS values of the expression in the row selected by the clause SELECT. The result is a value BIGINT.
CONCAT
Returns the string that Results from concatenating the Arguments.
In free translation:
Returns the string resulting from concatenating the arguments.
GROUP_CONCAT
This Function Returns a string result with the Concatenated non-NULL values from a group.
In free translation:
This function returns the string resulting from the concatenation of non-NON-NORS values of a group.
Was any of the answer helpful? Don’t forget to choose one and mark it so it can be used if someone has a similar question!
– Sorack