Skip to content

Commit 342e52e

Browse files
committed
window functions sql starter
1 parent a7ff27f commit 342e52e

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- SELECT CURRENT DATABASE
2+
SELECT DATABASE();
3+
4+
-- SHOW ALL DATABASES
5+
SHOW DATABASES;
6+
7+
-- CREATE AND SELECT DATABASE
8+
CREATE DATABASE win_funcs;
9+
USE win_funcs;
10+
11+
-- SHOW TABLES IN CURRENT DATABASE
12+
SHOW TABLES;
13+
14+
-- CREATE TABLE TO STORE EMPLOYEE DATA
15+
CREATE TABLE employees (
16+
emp_no INT PRIMARY KEY AUTO_INCREMENT,
17+
department VARCHAR(20),
18+
salary INT
19+
);
20+
21+
-- INSERT SAMPLE DATA INTO employees TABLE
22+
INSERT INTO employees (department, salary) VALUES
23+
('engineering', 80000),
24+
('engineering', 69000),
25+
('engineering', 70000),
26+
('engineering', 103000),
27+
('engineering', 67000),
28+
('engineering', 89000),
29+
('engineering', 91000),
30+
('sales', 59000),
31+
('sales', 70000),
32+
('sales', 159000),
33+
('sales', 72000),
34+
('sales', 60000),
35+
('sales', 61000),
36+
('sales', 61000),
37+
('customer service', 38000),
38+
('customer service', 45000),
39+
('customer service', 61000),
40+
('customer service', 40000),
41+
('customer service', 31000),
42+
('customer service', 56000),
43+
('customer service', 55000);
44+
45+
-- VIEW ALL RECORDS
46+
SELECT * FROM employees;

0 commit comments

Comments
 (0)