I have two queries, the first one generating a table like
SELECT COUNT(channel) AS messages FROM Chats WHERE message LIKE '%word%' GROUP BY UNIX_TIMESTAMP(time) DIV 3600
+-----+
| 123 |
| 127 |
| 332 |
| 219 |
+-----+
and the second one
SELECT COUNT(channel) AS messages FROM Chats GROUP BY UNIX_TIMESTAMP(time) DIV 3600
+-----+
| 222 |
| 579 |
| 590 |
| 377 |
+-----+
Now I would like to divide all results from the first table by the corresponding value in the second one (results rounded, had to calculate it manually):
+------+
| 0.55 | #123/222
| 0.46 | #127/279
| 0.56 | #332/590
| 0.58 | #219/377
+------+
Here's one way you can accomplish the whole thing by the following query:
Note:
If you want the result rounded up to 2 digits after the decimal point then use the following as the first line of the query:
Demo Here
Caution: You haven't used any ORDER BY in your query. You might get random behavior.