Home > Blockchain >  Get percentage of string in table
Get percentage of string in table

Time:07-03

I'm trying to get the precentage of a string in a table, but I don't know how to filter the string after counting and than dividing it. I tried this because I found it online, but it didn't work:

SELECT table.colum1, Count(table1.colum1) WHERE table1.colum1 LIKE "String" AS countString
FROM table1
GROUP BY table1.colum1 / (SELECT Count(table1.colum1) AS CountAll);

CodePudding user response:

Found out how to do it:

SELECT table1.colum1, Count(table1.colum1) / (SELECT Count(table.colum1) AS CountAll
FROM table1) AS PercentString  FROM table1 WHERE table1.colum1 = 'String'
GROUP BY table1.colum1;

Thanks for the help <3

  • Related