add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (
id INT,
source VARCHAR(32)
)
INSERT INTO test VALUES
(1, 'a'),
(2, 'a'),
(3, 'a'),
(4, 'b'),
(5, 'b')
5 rows affected
SELECT
*,
total_users * 100.0 / SUM(total_users) OVER () AS percentage_of_total
FROM
(
select source, count(*) as total_users
from test
group by source
)
totals_by_source
source total_users percentage_of_total
a 3 60.000000000000
b 2 40.000000000000