Skip to content
Query Prosentase Kehadiran
- DROP TABLE IF EXISTS provinsi;
- CREATE TABLE IF NOT EXISTS provinsi (
- id INT NOT NULL,
- nama tinytext NOT NULL,
- PRIMARY KEY (id)
- );
-
- INSERT INTO provinsi (id, nama) VALUES
- (1,‘Aceh’),
- (2,‘Sumatera Utara’),
- (3,‘Sumatera Barat’),
- (4,‘Riau’),
- (5,‘Jambi’),
- (6,‘Sumatera Selatan’),
- (7,‘Bengkulu’),
- (8,‘Lampung’),
- (9,‘Kepulauan Bangka Belitung’),
- (10,‘Kepulauan Riau’),
- (11,‘DKI Jakarta’),
- (12,‘Jawa Barat’),
- (13,‘Jawa Tengah’),
- (14,‘DI Yogyakarta’),
- (15,‘Jawa Timur’),
- (16,‘Banten’),
- (17,‘Bali’),
- (18,‘Nusa Tenggara Barat’),
- (19,‘Nusa Tenggara Timur’),
- (20,‘Kalimantan Barat’),
- (21,‘Kalimantan Tengah’),
- (22,‘Kalimantan Selatan’),
- (23,‘Kalimantan Timur’),
- (24,‘Kalimantan Utara’),
- (25,‘Sulawesi Utara’),
- (26,‘Sulawesi Tengah’),
- (27,‘Sulawesi Selatan’),
- (28,‘Sulawesi Tenggara’),
- (29,‘Gorontalo’),
- (30,‘Sulawesi Barat’),
- (31,‘Maluku’),
- (32,‘Maluku Utara’),
- (33,‘Papua Barat’),
- (34,‘Papua’);
-
- DROP TABLE IF EXISTS peserta;
- CREATE TABLE IF NOT EXISTS peserta(
- id INT AUTO_INCREMENT,
- nama VARCHAR(30),
- provinsi VARCHAR(30),
- PRIMARY KEY(id)
- );
-
- INSERT INTO peserta (nama,provinsi) VALUES
- (“Zachery Singleton”,24),
- (“Stewart Irwin”,13),
- (“Aaron Hall”,34),
- (“Eagan Francis”,32),
- (“Dolan Carrillo”,8),
- (“Victor Church”,7),
- (“Zachary Moreno”,30),
- (“Herman Jensen”,10),
- (“Devin Brady”,29),
- (“Paki Morton”,15),
- (“Beck Gregory”,15),
- (“Knox Sherman”,16),
- (“Keefe Mercer”,15),
- (“Kermit Walls”,19),
- (“Marvin Cooper”,1),
- (“Gary Davenport”,2),
- (“Quinn Giles”,18),
- (“Lev Sherman”,15),
- (“Erasmus Travis”,31),
- (“Herman Wagner”,18),
- (“Maxwell Harvey”,26),
- (“Jacob Cash”,11),
- (“Addison Weiss”,15),
- (“Marvin Patterson”,8),
- (“Fletcher Lindsay”,2),
- (“Nasim Spence”,9),
- (“Ray York”,5),
- (“Elvis Garrett”,30),
- (“Dalton Shannon”,14),
- (“Vance Hoffman”,18),
- (“Leo Guzman”,20),
- (“Odysseus Kane”,33),
- (“Arden Wilder”,6),
- (“Rudyard Dalton”,20),
- (“Driscoll Cote”,11),
- (“Brenden Morrow”,24),
- (“Martin Meadows”,12),
- (“Hayes Walter”,9),
- (“Keith Stark”,29),
- (“Kato Mosley”,10),
- (“Stephen Dennis”,9),
- (“Cyrus Chambers”,6),
- (“Garrison Dyer”,14),
- (“Aladdin King”,32),
- (“Dieter Strong”,15),
- (“Beau Pate”,7),
- (“Len Raymond”,17),
- (“Upton Bentley”,17),
- (“Addison Giles”,20),
- (“Channing Head”,10),
- (“Hasad Willis”,1),
- (“Kamal Avery”,29),
- (“Ira Barker”,25),
- (“Jermaine Schneider”,6),
- (“Ethan Wall”,14),
- (“Malachi Evans”,16),
- (“Amir Francis”,12),
- (“Daquan Vaughan”,13),
- (“Kennedy Jefferson”,2),
- (“Felix Marshall”,15),
- (“Garrison Matthews”,3),
- (“Fletcher Becker”,27),
- (“Oliver Johns”,30),
- (“Carlos Camacho”,29),
- (“Joseph Christensen”,29),
- (“Nicholas Howe”,16),
- (“Timothy Walls”,31),
- (“Hector Buckner”,33),
- (“Buckminster Hancock”,24),
- (“Derek Sawyer”,25),
- (“Seth Buckley”,11),
- (“Holmes Strickland”,7),
- (“Neville Mayer”,32),
- (“Allistair Holland”,23),
- (“Perry Moran”,30),
- (“Keefe Barr”,7),
- (“Palmer Whitfield”,29),
- (“Herman Campbell”,29),
- (“Ali Jacobson”,9),
- (“Francis Stevens”,14),
- (“Lyle Coleman”,1),
- (“Alec Navarro”,8),
- (“Allistair Rivas”,17),
- (“Ross Barron”,8),
- (“Mufutau Glover”,13),
- (“Harlan Small”,31),
- (“Davis Fleming”,8),
- (“Carl Sosa”,28),
- (“Lester Puckett”,12),
- (“Ronan Rhodes”,27),
- (“Giacomo Walon”,28),
- (“Lane Jacobson”,33),
- (“Paul Mills”,9),
- (“Tiger Shaffer”,22),
- (“Josiah Henson”,22),
- (“Darius Alston”,17),
- (“August Estes”,24),
- (“Chaney Chavez”,7),
- (“Channing Chavez”,29),
- (“Richard Bowen”,17);
-
-
- DROP TABLE IF EXISTS pertemuan_detail;
- CREATE TABLE IF NOT EXISTS pertemuan_detail(
- id INT AUTO_INCREMENT,
- parent_id INT,
- peserta_id INT,
- jam_hadir DATETIME,
- PRIMARY KEY (id)
- );
-
-
- INSERT INTO pertemuan_detail (id, parent_id, peserta_id, jam_hadir) VALUES
- (1, 1, 94, ‘2016-01-11 06:42:18’),
- (2, 1, 69, ‘2016-01-11 06:47:48’),
- (3, 1, 57, ‘2016-01-11 06:46:52’),
- (4, 1, 50, ‘2016-01-11 06:35:52’),
- (5, 1, 10, ‘2016-01-11 06:34:22’),
- (6, 1, 79, ‘2016-01-11 06:34:39’),
- (7, 1, 54, ‘2016-01-11 06:42:30’),
- (8, 1, 95, ‘2016-01-11 06:36:14’),
- (9, 1, 11, ‘2016-01-11 06:45:56’),
- (10, 1, 73, ‘2016-01-11 06:46:51’),
- (11, 1, 48, ‘2016-01-11 06:35:30’),
- (12, 1, 39, ‘2016-01-11 06:49:12’),
- (13, 1, 58, ‘2016-01-11 06:47:19’),
- (14, 1, 51, ‘2016-01-11 06:48:28’),
- (15, 1, 91, ‘2016-01-11 06:42:01’),
- (16, 1, 42, ‘2016-01-11 06:34:39’),
- (17, 1, 36, ‘2016-01-11 06:33:50’),
- (18, 1, 46, ‘2016-01-11 06:45:14’),
- (19, 1, 17, ‘2016-01-11 06:36:30’),
- (20, 1, 3, ‘2016-01-11 06:44:10’),
- (21, 1, 65, ‘2016-01-11 06:42:26’),
- (22, 1, 74, ‘2016-01-11 06:34:32’),
- (23, 1, 49, ‘2016-01-11 06:35:08’),
- (24, 1, 60, ‘2016-01-11 06:37:38’),
- (25, 1, 19, ‘2016-01-11 06:35:07’),
- (26, 1, 30, ‘2016-01-11 06:38:48’),
- (27, 1, 81, ‘2016-01-11 06:45:43’),
- (28, 1, 5, ‘2016-01-11 06:33:16’),
- (29, 1, 44, ‘2016-01-11 06:48:53’),
- (30, 1, 29, ‘2016-01-11 06:38:43’),
- (31, 1, 71, ‘2016-01-11 06:34:23’),
- (32, 1, 24, ‘2016-01-11 06:41:00’),
- (33, 1, 75, ‘2016-01-11 06:45:40’),
- (34, 1, 18, ‘2016-01-11 06:40:03’),
- (35, 1, 26, ‘2016-01-11 06:42:18’),
- (36, 1, 28, ‘2016-01-11 06:45:41’),
- (37, 1, 92, ‘2016-01-11 06:45:49’),
- (38, 1, 86, ‘2016-01-11 06:40:10’),
- (39, 1, 6, ‘2016-01-11 06:35:35’),
- (40, 1, 14, ‘2016-01-11 06:40:35’),
- (41, 1, 67, ‘2016-01-11 06:44:37’),
- (42, 1, 55, ‘2016-01-11 06:44:48’),
- (43, 1, 31, ‘2016-01-11 06:38:44’),
- (44, 1, 9, ‘2016-01-11 06:43:55’),
- (45, 1, 43, ‘2016-01-11 06:45:45’),
- (46, 1, 84, ‘2016-01-11 06:34:42’),
- (47, 1, 89, ‘2016-01-11 06:34:34’),
- (48, 1, 64, ‘2016-01-11 06:48:54’),
- (49, 1, 20, ‘2016-01-11 06:44:29’),
- (50, 1, 80, ‘2016-01-11 06:48:55’),
- (51, 1, 4, ‘2016-01-11 06:47:34’),
- (52, 1, 96, ‘2016-01-11 06:40:26’),
- (53, 1, 37, ‘2016-01-11 06:44:30’),
- (54, 1, 88, ‘2016-01-11 06:34:51’),
- (55, 1, 22, ‘2016-01-11 06:43:51’),
- (56, 1, 83, ‘2016-01-11 06:45:06’),
- (57, 1, 33, ‘2016-01-11 06:41:06’),
- (58, 1, 70, ‘2016-01-11 06:48:13’),
- (59, 1, 2, ‘2016-01-11 06:47:55’),
- (60, 1, 77, ‘2016-01-11 06:47:47’),
- (61, 1, 97, ‘2016-01-11 06:37:55’),
- (62, 1, 8, ‘2016-01-11 06:36:25’),
- (63, 1, 68, ‘2016-01-11 06:42:34’),
- (64, 1, 90, ‘2016-01-11 06:41:42’),
- (65, 1, 52, ‘2016-01-11 06:46:57’),
- (66, 1, 41, ‘2016-01-11 06:38:32’),
- (67, 1, 59, ‘2016-01-11 06:35:38’),
- (68, 1, 1, ‘2016-01-11 06:45:05’),
- (69, 1, 13, ‘2016-01-11 06:38:30’),
- (70, 1, 78, ‘2016-01-11 06:35:16’),
- (71, 1, 45, ‘2016-01-11 06:43:15’),
- (72, 1, 82, ‘2016-01-11 06:34:31’),
- (73, 1, 76, ‘2016-01-11 06:41:13’),
- (74, 1, 15, ‘2016-01-11 06:49:01’),
- (75, 1, 62, ‘2016-01-11 06:39:54’),
- (76, 1, 23, ‘2016-01-11 06:44:52’),
- (77, 1, 85, ‘2016-01-11 06:42:05’),
- (78, 1, 47, ‘2016-01-11 06:43:52’),
- (79, 1, 38, ‘2016-01-11 06:41:43’),
- (80, 1, 93, ‘2016-01-11 06:36:03’),
- (81, 1, 32, ‘2016-01-11 06:36:24’);
-
- SELECT b.id,b.nama AS provinsi,
- COUNT(*) AS jml,
- COUNT(c.peserta_id) AS hadir,
- CONCAT(TRUNCATE(COUNT(c.peserta_id)/COUNT(*)*100,0),‘%’) AS persen
- FROM peserta a
- RIGHT JOIN provinsi b ON b.id=a.provinsi
- LEFT JOIN pertemuan_detail c ON c.peserta_id=a.id
- GROUP BY b.id
-
- +—-+—————————+—–+——-+——–+
- | id | provinsi | jml | hadir | persen |
- +—-+—————————+—–+——-+——–+
- | 1 | Aceh | 3 | 3 | 100% |
- | 2 | Sumatera Utara | 3 | 1 | 33% |
- | 3 | Sumatera Barat | 1 | 0 | 0% |
- | 4 | Riau | 1 | 0 | 0% |
- | 5 | Jambi | 1 | 0 | 0% |
- | 6 | Sumatera Selatan | 3 | 3 | 100% |
- | 7 | Bengkulu | 5 | 3 | 60% |
- | 8 | Lampung | 5 | 4 | 80% |
- | 9 | Kepulauan Bangka Belitung | 5 | 5 | 100% |
- | 10 | Kepulauan Riau | 3 | 2 | 66% |
- | 11 | DKI Jakarta | 3 | 2 | 66% |
- | 12 | Jawa Barat | 3 | 3 | 100% |
- | 13 | Jawa Tengah | 3 | 3 | 100% |
- | 14 | DI Yogyakarta | 4 | 4 | 100% |
- | 15 | Jawa Timur | 7 | 7 | 100% |
- | 16 | Banten | 3 | 0 | 0% |
- | 17 | Bali | 5 | 4 | 80% |
- | 18 | Nusa Tenggara Barat | 3 | 3 | 100% |
- | 19 | Nusa Tenggara Timur | 1 | 1 | 100% |
- | 20 | Kalimantan Barat | 3 | 2 | 66% |
- | 21 | Kalimantan Tengah | 1 | 0 | 0% |
- | 22 | Kalimantan Selatan | 2 | 2 | 100% |
- | 23 | Kalimantan Timur | 1 | 1 | 100% |
- | 24 | Kalimantan Utara | 4 | 4 | 100% |
- | 25 | Sulawesi Utara | 2 | 1 | 50% |
- | 26 | Sulawesi Tengah | 1 | 0 | 0% |
- | 27 | Sulawesi Selatan | 2 | 2 | 100% |
- | 28 | Sulawesi Tenggara | 2 | 2 | 100% |
- | 29 | Gorontalo | 8 | 7 | 87% |
- | 30 | Sulawesi Barat | 4 | 2 | 50% |
- | 31 | Maluku | 3 | 3 | 100% |
- | 32 | Maluku Utara | 3 | 3 | 100% |
- | 33 | Papua Barat | 3 | 3 | 100% |
- | 34 | Papua | 1 | 1 | 100% |
- +—-+—————————+—–+——-+——–+
- 34 rows in set (0.01 sec)
https://www.cahyadsn.com/detail_snippet.php?id=eG#