``` sql ```SELECT A.script_name, A.count, (A.count...
# exposed
m
Copy code
sql
```SELECT A.script_name, A.count, (A.count * 100) / totalCount AS percentage, totalCount
FROM (SELECT script_name, COUNT(*) AS count FROM sessions WHERE client_username = "Miha" GROUP BY script_name) AS A
         INNER JOIN (SELECT COUNT(*) AS totalCount FROM sessions WHERE client_username = "Miha") AS B
GROUP BY A.script_name
``` Can anyone help me write this in Exposed kotlin? I’ve tried using aliases but was never able to select totalCount from a subquery or the main query.
t
Could you explain what do you expect to achieve with this query as I can't see any condition for INNER JOIN and also there is no usage of B table.
m
I have a table from which i’d like to calculate the percentage of the rows belong to a certain script_name