forked from bbrumm/databasestar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_data_rank.sql
53 lines (47 loc) · 1.61 KB
/
sample_data_rank.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Sample data for SQL RANK and DENSE_RANK examples
Post here: https://www.databasestar.com/sql-rank/
*/
/*
Oracle
*/
CREATE TABLE student (
student_id NUMBER,
first_name VARCHAR2(100),
last_name VARCHAR2(100),
fees_paid NUMBER,
gender VARCHAR2(1)
);
/*
SQL Server, MySQL, Postgres
*/
CREATE TABLE student (
student_id INT,
first_name VARCHAR(100),
last_name VARCHAR(100),
fees_paid INT,
gender VARCHAR(1)
);
/*
Insert (for all vendors)
*/
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (1, 'John', 'Smith', 200, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (2, 'Susan', 'Johnson', 500, 'F');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (3, 'Tom', 'Capper', 350, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (4, 'Mark', 'Holloway', 100, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (5, 'Steven', 'Webber', 0, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (6, 'Julie', 'Armstrong', 150, 'F');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (7, 'Michelle', 'Randall', 150, 'F');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (8, 'Andrew', 'Cooper', 800, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (9, 'Robert', 'Pickering', 900, 'M');
INSERT INTO student (student_id, first_name, last_name, fees_paid, gender)
VALUES (10, 'Tanya', 'Hall', 50, 'F');