We have come to the end of another course and now you have a good understanding what SQL can do.
Download the class notes for day 10.
Just another CUNY Academic Commons site
We have come to the end of another course and now you have a good understanding what SQL can do.
Download the class notes for day 10.
We are reaching the end of the course and this means programmability.
CREATE PROCEDURE quick_example @in_param VARCHAR(50) -- passing a value into the procedure using parameter -- `@in_param` declared as a VARCHAR(50) AS BEGIN -- beginning of code do something when executing this -- procedure DECLARE @out_param VARCHAR(50) -- receive value from it has been processed, using -- the same data type (VARCHAR(50)) SET @out_param = CONCAT ( '`', @in_param, '` processed as `', UPPER(@in_param), '`' ) -- passing a value. the original value processed PRINT @out_param -- printing the value of the output parameter -- end of code to do something when executing this procedure END;
Download the class notes for day 8.
We continue creating and altering database objects. Now all the material you have learned will be used when creating views.
Download the class notes for day 7.
We are half-way done with the course. We are now creating, dropping and altering objects.
CREATE obj_type obj_name [some_code] CREATE DATABASE db_name; CREATE SCHEMA schema_name; CREATE TABLE table_name; ( field_1 datatype_1 [atributes], field_2 datatype_2 [atributes], field_3 datatype_3 [atributes], ... ); CREATE VIEW view_table AS ( SELECT fields... FROM table(s) );
Download the class notes for day 6.
We have worked with data coming from one function fed into another. We need to keep in mind that the process starts from the inside out.
function_5(some_value5... function_4(some_value4... function_3(some_value3... function_2(some_value2... function_1(some_value1... ) -- output of function_1 into function_2 ) -- output of function_2 into function_3 ) -- output of function_3 into function_4 ) -- output of function_4 into function_5 ) -- output of function_5
We have seen functions that affect strings and numeric values including `FORMAT()` to change the look of dates and currencies. Doing the latter changes the value from a numeric value to a string by default in SQL Server to `NVARCHAR(n)`.
Download the class notes for day 5.
We have started putting logic in our code to avoid logical errors.
CASE WHEN condition1 THEN action1 WHEN condition2 THEN action2 ELSE escape_action END
Download the class notes for day 4.
Download the instructions. Follow these steps with admin privileges.
As we continue having fun with SQL, we have started working with functions and manipulating the output of our queries. Download the class notes for day 3.
By the way, we can use https://sf21job.slack.com/ to share questions and help one another (another way to learn).
We are finally playing with data. To request data from a table or group of, we need to follow the following structure for the SELECT statement. Any changes in the syntax will break the statement and return an error.
SELECT table1.field1, table1.field2... table2.field1, table2.field2... FROM table1 INNER | (OUTER) LEFT | (OUTER) RIGHT table2 ON table1.common_field1 = table2.common_field1...;
Download the class notes for day 2.
We have started a new course. We took care of the installation of SQL Server Express and SQL Server Management Studio (SSMS) on Windows machines. Download the class notes for day 1.