diff --git a/NOTICE b/NOTICE index 547595f..4851a73 100644 --- a/NOTICE +++ b/NOTICE @@ -4,9 +4,6 @@ All Rights Reserved. Licensed under the LinkedIn Learning Exercise File License (the "License"). See LICENSE in the project root for license information. -ATTRIBUTIONS: -[PLEASE PROVIDE ATTRIBUTIONS OR DELETE THIS AND THE ABOVE LINE “ATTRIBUTIONS”] - Please note, this project may automatically load third party code from external repositories (for example, NPM modules, Composer packages, or other dependencies). If so, such third party code may be subject to other license terms than as set diff --git a/README.md b/README.md index 422e093..ba1fe29 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -# COURSENAME -This is the repository for the LinkedIn Learning course `course-name`. The full course is available from [LinkedIn Learning][lil-course-url]. +# Hands-On Introduction: SQL +This is the repository for the LinkedIn Learning course Hands-On Introduction: SQL. The full course is available from [LinkedIn Learning][lil-course-url]. + +![Hands-On Introduction: SQL ][lil-thumbnail-url] + +Join instructor Deepa Maddala as she uses hands-on lessons to teach you the tools, techniques, and know-how that you need to start using SQL from day one. Deepa guides you through using the Select statement to fetch and filter data, creating and adding to tables and data, modifying existing tables, and what to use in different scenarios. She includes simple examples with each topic she covers.

The best way to learn a language is to use it in practice. That’s why this course is integrated with GitHub Codespaces, an instant cloud developer environment that offers all the functionality of your favorite IDE without the need for any local machine setup. With GitHub Codespaces, you can get hands-on practice from any machine, at any time—all while using a tool that you’ll likely encounter in the workplace. Check out the [Using GitHub Codespaces with this course][gcs-video-url] video to learn how to get started. -![course-name-alt-text][lil-thumbnail-url] -_See the readme file in the main branch for updated instructions and information._ ## Instructions This repository has branches for each of the videos in the course. You can use the branch pop up menu in github to switch to a specific branch and take a look at the course at that stage, or you can add `/tree/BRANCH_NAME` to the URL to go to the branch you want to access. @@ -22,15 +24,13 @@ To resolve this issue: Add changes to git using this command: git add . Commit changes using this command: git commit -m "some message" -## Installing -1. To use these exercise files, you must have the following installed: - - [list of requirements for course] -2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. -3. [Course-specific instructions] +### Instructor -[0]: # (Replace these placeholder URLs with actual course URLs) +Deepa Maddala -[lil-course-url]: https://www.linkedin.com/learning/ -[lil-thumbnail-url]: http:// +Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/deepa-maddala?u=104). +[lil-course-url]: https://www.linkedin.com/learning/hands-on-introduction-sql +[lil-thumbnail-url]: https://media.licdn.com/dms/image/D560DAQFce8T-RjMmAg/learning-public-crop_675_1200/0/1667324559752?e=1667955600&v=beta&t=fSwTEREJ2cKzBWmkRcZcirnwL306jvMsnhG0fjLRayA +[gcs-video-url]: https://www.linkedin.com/learning/hands-on-introduction-sql/using-github-codespaces-with-this-course diff --git a/database.db b/database.db new file mode 100644 index 0000000..44b2523 Binary files /dev/null and b/database.db differ diff --git a/queries/createTable.sql b/queries/00_01/createTable.sql similarity index 100% rename from queries/createTable.sql rename to queries/00_01/createTable.sql diff --git a/queries/00_01/create_dept_copy_tab.sql b/queries/00_01/create_dept_copy_tab.sql new file mode 100644 index 0000000..8eb1445 --- /dev/null +++ b/queries/00_01/create_dept_copy_tab.sql @@ -0,0 +1,7 @@ +CREATE TABLE dept_copy_tab +( + deptno NUMBER, + dname VARCHAR2(50), + mgr_id NUMBER(10), + location_id NUMBER(10) +); diff --git a/queries/00_01/create_dept_table.sql b/queries/00_01/create_dept_table.sql new file mode 100644 index 0000000..161df7f --- /dev/null +++ b/queries/00_01/create_dept_table.sql @@ -0,0 +1,8 @@ +CREATE TABLE dept_tab +( + deptno NUMBER(5), + dname VARCHAR2(50), + mgr_id NUMBER(10), + location_id NUMBER(10), + CONSTRAINT pk_dept_tab PRIMARY KEY (deptno) +); \ No newline at end of file diff --git a/queries/00_01/create_emp_table.sql b/queries/00_01/create_emp_table.sql new file mode 100644 index 0000000..b1e2047 --- /dev/null +++ b/queries/00_01/create_emp_table.sql @@ -0,0 +1,14 @@ +CREATE TABLE emp_tab +( + empno NUMBER, + name VARCHAR2(50) NOT NULL, + job VARCHAR2(50), + manager NUMBER(10), + hiredate DATE, + salary NUMBER(10,2), + commission NUMBER(10,2), + deptno NUMBER(5), + CONSTRAINT pk_emp_tab PRIMARY KEY (empno), + CONSTRAINT fk_emp_tab_deptno FOREIGN KEY (deptno) + REFERENCES dept_tab(deptno) +); \ No newline at end of file diff --git a/queries/00_01/create_old_emp_table.sql b/queries/00_01/create_old_emp_table.sql new file mode 100644 index 0000000..a44ae24 --- /dev/null +++ b/queries/00_01/create_old_emp_table.sql @@ -0,0 +1,11 @@ +CREATE TABLE old_emp_tab +( + empno NUMBER, + name VARCHAR2(50) not null, + job VARCHAR2(50), + manager NUMBER(10), + hiredate DATE, + salary NUMBER(10,2), + commission NUMBER(10,2), + deptno NUMBER(5) +); \ No newline at end of file diff --git a/queries/00_01/insert_dept_table.sql b/queries/00_01/insert_dept_table.sql new file mode 100644 index 0000000..657bbb4 --- /dev/null +++ b/queries/00_01/insert_dept_table.sql @@ -0,0 +1,162 @@ +INSERT INTO dept_tab VALUES + ( 30 + , 'Purchasing' + , 114 + , 1700 + ); + + INSERT INTO dept_tab VALUES + ( 40 + , 'Human Resources' + , 203 + , 2400 + ); + + + + INSERT INTO dept_tab VALUES + ( 70 + , 'Public Relations' + , 204 + , 2700 + ); + + INSERT INTO dept_tab VALUES + ( 80 + , 'Sales' + , 145 + , 2500 + ); + + INSERT INTO dept_tab VALUES + ( 90 + , 'Executive' + , 100 + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 100 + , 'Finance' + , 108 + , 1700 + ); + + INSERT INTO dept_tab VALUES + ( 110 + , 'Accounting' + , 205 + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 120 + , 'Treasury' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 130 + , 'Corporate Tax' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 140 + , 'Control And Credit' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 150 + , 'Shareholder Services' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 160 + , 'Benefits' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 170 + , 'Manufacturing' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 180 + , 'Construction' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 190 + , 'Contracting' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 200 + , 'Operations' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 210 + , 'IT Support' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 220 + , 'NOC' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 230 + , 'IT Helpdesk' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 240 + , 'Government Sales' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 250 + , 'Retail Sales' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 260 + , 'Recruiting' + , NULL + , 1700 + ); + +INSERT INTO dept_tab VALUES + ( 270 + , 'Payroll' + , NULL + , 1700 + ); \ No newline at end of file diff --git a/queries/00_01/insert_emp_table.sql b/queries/00_01/insert_emp_table.sql new file mode 100644 index 0000000..0e224f7 --- /dev/null +++ b/queries/00_01/insert_emp_table.sql @@ -0,0 +1,44 @@ +INSERT INTO emp_tab +VALUES(7001, 'KING', 'PRESIDENT', null, + date('1981-11-17'), 5000, 1000, 40); + +INSERT INTO emp_tab +VALUES(7002, 'CLARK', 'MANAGER', 7001, + date('1981-06-09'), 2450, 500, 40 +); + +INSERT INTO emp_tab +VALUES(7003, 'JONES', 'MANAGER', 7001, + date('1981-04-02'),2975, 500, 30 +); + +INSERT INTO emp_tab + VALUES(7004, 'SCOTT', 'ANALYST', 7002, + date('1987-08-13'), 3000, 300, 70 +); + +INSERT INTO emp_tab +VALUES(7005, 'FORD', 'ANALYST', 7002, +date('1981-12-03'),3000, 300, 30 +); + +INSERT INTO emp_tab + VALUES(7006, 'SMITH', 'CLERK', 7003, + date('1980-12-17'),800, 200, 30 +); + +INSERT INTO emp_tab +VALUES(7007, 'ADAMS', 'CLERK', 7003, + date('1987-08-13'), 1100, 200, 40 +); + +INSERT INTO emp_tab +VALUES( + 7008, 'MILLER', 'CLERK', 7003, + date('1982-01-23'), 1300, 200, 30 +); + +DELETE FROM emp_tab WHERE empno=7005; + + + diff --git a/queries/00_01/insert_old_emp_table.sql b/queries/00_01/insert_old_emp_table.sql new file mode 100644 index 0000000..9f2071a --- /dev/null +++ b/queries/00_01/insert_old_emp_table.sql @@ -0,0 +1,42 @@ +INSERT INTO old_emp_tab +VALUES(7001, 'KING', 'PRESIDENT', null, + date('1981-11-17'), 5000, 1000, 40); + +INSERT INTO old_emp_tab +VALUES(7002, 'CLARK', 'MANAGER', 7001, + date('1981-06-09'), 2450, 500, 40 +); + +INSERT INTO old_emp_tab +VALUES(7003, 'JONES', 'MANAGER', 7001, + date('1981-04-02'),2975, 500, 30 +); + +INSERT INTO old_emp_tab + VALUES(7004, 'SCOTT', 'ANALYST', 7002, + date('1987-08-13'), 3000, 300, 70 +); + +INSERT INTO old_emp_tab +VALUES(7005, 'FORD', 'ANALYST', 7002, +date('1981-12-03'),3000, 300, 30 +); + +INSERT INTO old_emp_tab + VALUES(7006, 'SMITH', 'CLERK', 7003, + date('1980-12-17'),800, 200, 30 +); + +INSERT INTO old_emp_tab +VALUES(7007, 'ADAMS', 'CLERK', 7003, + date('1987-08-13'), 1100, 200, 40 +); + +INSERT INTO old_emp_tab +VALUES( + 7008, 'MILLER', 'CLERK', 7003, + date('1982-01-23'), 1300, 200, 30 +); + + + diff --git a/queries/query_Insert.sql b/queries/00_01/query_Insert.sql similarity index 100% rename from queries/query_Insert.sql rename to queries/00_01/query_Insert.sql diff --git a/queries/00_01/select.sql b/queries/00_01/select.sql new file mode 100644 index 0000000..3ddae20 --- /dev/null +++ b/queries/00_01/select.sql @@ -0,0 +1 @@ +select * from dept_tab; \ No newline at end of file diff --git a/queries/00_01/selectAll.sql b/queries/00_01/selectAll.sql new file mode 100644 index 0000000..05c8bc0 --- /dev/null +++ b/queries/00_01/selectAll.sql @@ -0,0 +1,2 @@ +-- SQLite +SELECT * FROM emp_tab; \ No newline at end of file diff --git a/queries/01_02/ComparisonConditions.sql b/queries/01_02/ComparisonConditions.sql new file mode 100644 index 0000000..6c3f224 --- /dev/null +++ b/queries/01_02/ComparisonConditions.sql @@ -0,0 +1,12 @@ +SELECT empno, name,hiredate +FROM emp_tab +WHERE name LIKE '_D%'; + +SELECT * FROM emp_tab +WHERE deptno IN (30,40); + +SELECT * FROM emp_tab +WHERE salary BETWEEN 2000 AND 6000; + +SELECT empno FROM emp_tab +WHERE manager IS NULL; \ No newline at end of file diff --git a/queries/01_02/LogicalConditions.sql b/queries/01_02/LogicalConditions.sql new file mode 100644 index 0000000..e1c3a75 --- /dev/null +++ b/queries/01_02/LogicalConditions.sql @@ -0,0 +1,8 @@ +SELECT * FROM emp_tab +WHERE name LIKE 'S%' AND deptno=30; + +SELECT * FROM emp_tab +WHERE name LIKE 'S%' OR deptno=30; + +SELECT * FROM emp_tab +WHERE deptno NOT IN(30,40); \ No newline at end of file diff --git a/queries/01_02/ORDERBY.sql b/queries/01_02/ORDERBY.sql new file mode 100644 index 0000000..cd2dbed --- /dev/null +++ b/queries/01_02/ORDERBY.sql @@ -0,0 +1,5 @@ +SELECT * FROM emp_tab +WHERE deptno=30 ORDER BY salary; + +SELECT * FROM emp_tab +ORDER BY deptno,salary DESC; \ No newline at end of file diff --git a/queries/01_02/OrderOfPrecedence.sql b/queries/01_02/OrderOfPrecedence.sql new file mode 100644 index 0000000..3524eab --- /dev/null +++ b/queries/01_02/OrderOfPrecedence.sql @@ -0,0 +1,9 @@ +SELECT empno,name,deptno,salary +FROM emp_tab +WHERE deptno=30 OR deptno=40 +AND salary>2500; + +SELECT empno,name,deptno,salary +FROM emp_tab +WHERE (deptno=30 OR deptno=40) +AND salary>2500; \ No newline at end of file diff --git a/queries/01_02/WHEREcondition.sql b/queries/01_02/WHEREcondition.sql new file mode 100644 index 0000000..2c769f7 --- /dev/null +++ b/queries/01_02/WHEREcondition.sql @@ -0,0 +1,7 @@ +SELECT empno,name,salary +FROM emp_tab +WHERE salary>2500; + +SELECT empno,name, salary +FROM emp_tab +WHERE name='KING'; \ No newline at end of file diff --git a/queries/selectAll.sql b/queries/selectAll.sql deleted file mode 100644 index e082d25..0000000 --- a/queries/selectAll.sql +++ /dev/null @@ -1,2 +0,0 @@ --- SQLite -SELECT * FROM USER; \ No newline at end of file diff --git a/test.db b/test.db deleted file mode 100644 index 936911b..0000000 Binary files a/test.db and /dev/null differ