Skip to content

Commit

Permalink
Solve Most Frequent in sql
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Sep 28, 2024
1 parent 0ee6bb7 commit a9816d5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions solutions/beecrowd/2993/2993.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT amount as most_frequent_value
FROM value_table
GROUP BY amount
ORDER BY COUNT(*) DESC
LIMIT 1;
1 change: 1 addition & 0 deletions solutions/beecrowd/2993/drop-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE value_table;
5 changes: 5 additions & 0 deletions solutions/beecrowd/2993/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
most_frequent_value
---------------------
1
(1 row)

6 changes: 6 additions & 0 deletions solutions/beecrowd/2993/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
https://judge.beecrowd.com/en/problems/view/2993

# Most Frequent

Given a single-column table with integers values, which is the most frequent
value, in other words, the statistical mode of the values?
18 changes: 18 additions & 0 deletions solutions/beecrowd/2993/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- URI Online Judge SQL
--- Copyright URI Online Judge
--- www.urionlinejudge.com.br
--- Problem 2993

CREATE TABLE value_table (
amount integer
);

-- GRANT SELECT ON value_table TO sql_user;

insert into
value_table (amount)
values
(4),(6),(7),(1),(1),(2),(3),(2),(3),(1),(5),(6),(1),(7),(8),(9),(10),(11),(12),(4),(5),(5),(3),(6),(2),(2),(1);

/* Execute this query to drop the tables */
-- DROP TABLE value_table;
1 change: 1 addition & 0 deletions solutions/beecrowd/2993/tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sql

0 comments on commit a9816d5

Please sign in to comment.