Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE users ( id serial, country_id int ); INSERT INTO users (country_id) VALUES (1),(1),(1),(2),(2),(3); SELECT * FROM users; select distinct country_id, round( ((COUNT(*) OVER (partition by country_id )) * 100)::numeric / COUNT(*) OVER () , 2) as percent from users order by country_id ;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear