https://kotlinlang.org logo
#exposed
Title
# exposed
m

Mihael

05/25/2019, 8:29 PM
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

tapac

05/29/2019, 12:29 PM
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

Mihael

05/29/2019, 10:28 PM
I have a table from which i’d like to calculate the percentage of the rows belong to a certain script_name
3 Views