Last active
March 6, 2022 10:05
-
-
Save kiransabne04/6a042eae3982b00465b0a935db408bc1 to your computer and use it in GitHub Desktop.
example dataset for SQL Server Windows Function for My Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table departments ( | |
id INT PRIMARY KEY, | |
name VARCHAR(50) | |
); | |
insert into departments (id, name) values (1, 'Research and Development'); | |
insert into departments (id, name) values (2, 'Sales'); | |
insert into departments (id, name) values (3, 'Support'); | |
insert into departments (id, name) values (4, 'Marketing'); | |
insert into departments (id, name) values (5, 'Product Management'); | |
insert into departments (id, name) values (6, 'IT & Support'); | |
insert into departments (id, name) values (7, 'Sales'); | |
insert into departments (id, name) values (8, 'Accounting'); | |
insert into departments (id, name) values (9, 'Software Development'); | |
insert into departments (id, name) values (10, 'After-Sales Services'); | |
create table employees ( | |
id INT, | |
first_name VARCHAR(50), | |
last_name VARCHAR(50), | |
department_id INT, | |
salary DECIMAL(9,2), | |
worked_years INT, | |
gender char(1) not null, | |
FOREIGN KEY(department_id) REFERENCES departments(id) | |
); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (1, 'Trstram', 'Knoble', 8, 645558.82, 3, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (2, 'Dennie', 'Brakewell', 1, 237629.63, 7, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (3, 'Peirce', 'Kless', 7, 237629.63, 3, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (4, 'Annalise', 'Exter', 10, 542225.42, 2, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (5, 'Daniele', 'Ewart', 5, 256954.43, 10, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (6, 'Wendy', 'Obert', 10, 22253.67, 6, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (7, 'Becka', 'Mozzi', 6, 187168.85, 1, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (8, 'Angie', 'Lamers', 4, 331565.45, 2, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (9, 'Carlin', 'De Gregario', 1, 350022.79, 1, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (10, 'Flemming', 'Flewett', 1, 1130774.23, 9, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (11, 'Conney', 'Primo', 3, 901992.56, 4, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (12, 'Ranique', 'Calladine', 6, 1053335.24, 8, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (13, 'Ava', 'Darkin', 9, 905076.24, 3, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (14, 'Lev', 'Sivorn', 8, 1019690.69, 3, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (15, 'Courtnay', 'Bamber', 10, 110557.49, 6, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (16, 'Mohandis', 'Casali', 10, 1174272.45, 3, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (17, 'Davey', 'McLeese', 3, 628024.5, 1, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (18, 'Minny', 'Hargate', 3, 622546.77, 10, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (19, 'Mariya', 'Goodbody', 4, 697652.91, 6, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (20, 'Ennis', 'Redler', 7, 1077886.94, 10, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (21, 'Di', 'Jervois', 3, 842200.95, 7, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (22, 'Natassia', 'McCloud', 9, 1119077.37, 3, 'O'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (23, 'Liane', 'Maruska', 7, 435104.75, 4, 'O'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (24, 'Harrietta', 'Clymo', 8, 461633.68, 10, 'O'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (25, 'Felicle', 'Likly', 3, 168324.95, 7, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (26, 'Inness', 'Tanser', 5, 611647.93, 2, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (27, 'Clarabelle', 'Mathonnet', 6, 589136.22, 10, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (28, 'Danny', 'Jerram', 9, 786369.55, 5, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (29, 'Marve', 'Duggleby', 2, 368592.68, 5, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (30, 'Alleen', 'Delacote', 7, 82850.51, 6, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (31, 'Ruthanne', 'Allflatt', 4, 601341.92, 2, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (32, 'Darrelle', 'McKelloch', 9, 294394.24, 5, 'F'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (33, 'Jimmie', 'Phelipeau', 7, 1143000.12, 8, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (34, 'Brewer', 'Champken', 4, 794632.43, 9, 'M'); | |
insert into employees (id, first_name, last_name, department_id, salary, worked_years, gender) values (35, 'Andra', 'Cockcroft', 10, 1064688.23, 3, 'F'); | |
create table department_expenses ( | |
id INT, | |
department_id INT, | |
item VARCHAR(30), | |
price DECIMAL(8,2), | |
FOREIGN KEY(department_id) REFERENCES departments(id) | |
); | |
insert into department_expenses (id, department_id, item, price) values (1, 5, 'printer', 80776.84); | |
insert into department_expenses (id, department_id, item, price) values (2, 3, 'monitor', 26231.19); | |
insert into department_expenses (id, department_id, item, price) values (3, 2, 'desktop', 43495.54); | |
insert into department_expenses (id, department_id, item, price) values (4, 1, 'desks', 49397.05); | |
insert into department_expenses (id, department_id, item, price) values (5, 8, 'Monthly stationary', 38820.91); | |
insert into department_expenses (id, department_id, item, price) values (6, 4, 'laptop', 54314.14); | |
insert into department_expenses (id, department_id, item, price) values (7, 5, 'laptop', 37002.05); | |
insert into department_expenses (id, department_id, item, price) values (8, 6, 'printer', 33931.41); | |
insert into department_expenses (id, department_id, item, price) values (9, 7, 'desks', 33645.13); | |
insert into department_expenses (id, department_id, item, price) values (10, 9, 'monitor', 35375.31); | |
insert into department_expenses (id, department_id, item, price) values (11, 9, 'Monthly stationary', 38820.91); | |
drop table if exists dbo.daily_revenue; | |
CREATE TABLE dbo.daily_revenue( | |
date date NOT NULL, | |
amount numeric(10, 2) NOT NULL | |
) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-22' AS Date), CAST(6660.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-03' AS Date), CAST(8431.62 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-11' AS Date), CAST(1588.48 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-01' AS Date), CAST(7769.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-07-24' AS Date), CAST(9273.53 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-09-30' AS Date), CAST(2094.20 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-02-12' AS Date), CAST(7923.16 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-11' AS Date), CAST(45646.48 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-01' AS Date), CAST(466.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-07-24' AS Date), CAST(9546.53 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-06-17' AS Date), CAST(7026.66 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-27' AS Date), CAST(6766.42 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-15' AS Date), CAST(1172.48 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-05-16' AS Date), CAST(7693.74 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-02' AS Date), CAST(5484.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-05-13' AS Date), CAST(64568.26 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-02' AS Date), CAST(416.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-05-13' AS Date), CAST(2514.26 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-12-02' AS Date), CAST(5456.18 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-05-13' AS Date), CAST(48658.26 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-08-27' AS Date), CAST(3099.39 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-02-14' AS Date), CAST(4045.74 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-01-09' AS Date), CAST(4919.60 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-02-22' AS Date), CAST(5615.51 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-01-18' AS Date), CAST(2466.82 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-05-23' AS Date), CAST(9807.79 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-09-15' AS Date), CAST(2679.22 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2022-01-05' AS Date), CAST(3473.71 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-08-19' AS Date), CAST(3260.89 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-20' AS Date), CAST(4883.54 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-10-31' AS Date), CAST(2498.17 AS Numeric(10, 2))) | |
GO | |
INSERT dbo.daily_revenue (date, amount) VALUES (CAST(N'2021-11-14' AS Date), CAST(7787.83 AS Numeric(10, 2))) | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment