0

This is my sample table, is it possible to get the distinct value of animals and get its letter with commas and count the letter of specific animals?

Query: Select animals, letter From pet;

 +--------------+--------------+
 | animals      | letter       |
 +--------------+--------------+
 | dog          |    d         |
 | dog          |    o         |
 | dog          |    g         |
 | cat          |    c         |
 | cat          |    a         |
 | cat          |    t         |
 | mouse        |    m         |
 | mouse        |    s         |
 | mouse        |    e         |
 +--------------+--------------+

This is my expected output, count the letter to get total, count every item before the comma symbol,:

 +--------------+--------------+--------------+
 | animals      | letter       |   total      |
 +--------------+--------------+--------------+
 | dog          |    d,o,g     |     3        |
 | cat          |    c,a,t     |     3        |
 | mouse        |    m,s,e     |     3        |
 +--------------+--------------+--------------+
Top Out
  • 23
  • 2
  • 7

0 Answers0