Add sql roadmap

pull/6443/head
Kamran Ahmed 4 months ago
parent 169a8f0356
commit 72f4faaf67
  1. 2
      src/components/EditorRoadmap/EditorRoadmap.tsx
  2. 2
      src/data/guides/devops-vs-sre.md
  3. 2
      src/data/guides/frontend-developer-skills.md
  4. 2
      src/data/guides/full-stack-developer-skills.md
  5. 2
      src/data/guides/how-to-become-devops-engineer.md
  6. 54
      src/data/roadmaps/sql/content/101-basic-syntax/statements/100-select.md
  7. 37
      src/data/roadmaps/sql/content/101-basic-syntax/statements/101-insert.md
  8. 45
      src/data/roadmaps/sql/content/101-basic-syntax/statements/102-update.md
  9. 30
      src/data/roadmaps/sql/content/101-basic-syntax/statements/103-delete.md
  10. 1
      src/data/roadmaps/sql/content/101-basic-syntax/statements/index.md
  11. 73
      src/data/roadmaps/sql/content/104-aggregate-queries/100-select.md
  12. 62
      src/data/roadmaps/sql/content/107-sub-queries/100-types/index.md
  13. 71
      src/data/roadmaps/sql/content/108-advanced-sql-functions/100-numeric.md
  14. 91
      src/data/roadmaps/sql/content/108-advanced-sql-functions/101-string/index.md
  15. 67
      src/data/roadmaps/sql/content/108-advanced-sql-functions/102-conditional/index.md
  16. 47
      src/data/roadmaps/sql/content/108-advanced-sql-functions/103-date-time/index.md
  17. 65
      src/data/roadmaps/sql/content/114-perf-optimization/100-query-optimization/index.md
  18. 0
      src/data/roadmaps/sql/content/abs@6vYFb_D1N_-tLWZftL-Az.md
  19. 0
      src/data/roadmaps/sql/content/acid@igg34gLPl3HYVAmRNFGcV.md
  20. 0
      src/data/roadmaps/sql/content/advanced-functions@vTMd0bqz4eTgLnhfgY61h.md
  21. 0
      src/data/roadmaps/sql/content/advanced-sql@UDqbT1y-YzBrljfKSz_RG.md
  22. 0
      src/data/roadmaps/sql/content/aggregate-queries@LX9nzJ4uqznHN4SksoDvr.md
  23. 0
      src/data/roadmaps/sql/content/alter-table@WjXlO42WL9saDS7RIGapt.md
  24. 0
      src/data/roadmaps/sql/content/avg@Wou6YXLYUgomvcELh851L.md
  25. 0
      src/data/roadmaps/sql/content/basic-sql-syntax@JDDG4KfhtIlw1rkNCzUli.md
  26. 0
      src/data/roadmaps/sql/content/begin@7sTW1vwUhCFOMXYjScVEt.md
  27. 0
      src/data/roadmaps/sql/content/case@W2ePJHdfEiEJ3ZKoRQKt_.md
  28. 0
      src/data/roadmaps/sql/content/ceiling@BAqJQvcguhIhzyII5LRH6.md
  29. 0
      src/data/roadmaps/sql/content/check@Q0h9Wfnl_W9ThOkv7Q17A.md
  30. 0
      src/data/roadmaps/sql/content/coalesce@k7lZe4QRt9q4InUImFmvx.md
  31. 0
      src/data/roadmaps/sql/content/column@wmtt-3auWLdQWuVdwZLPd.md
  32. 0
      src/data/roadmaps/sql/content/commit@3cMECz5QPVDOFrk5duObs.md
  33. 0
      src/data/roadmaps/sql/content/common-table-expressions@tedQynR0xicVKhuR1oahw.md
  34. 0
      src/data/roadmaps/sql/content/concat@5inpEqafeVCfqsURHzQQg.md
  35. 0
      src/data/roadmaps/sql/content/correlated-subqueries@JZqS3Xapw6mfSPVgFW7av.md
  36. 0
      src/data/roadmaps/sql/content/count@9aHYrOQDkA84tlxcVK5aD.md
  37. 0
      src/data/roadmaps/sql/content/create-table@epEpBxRosLhuAuKwp823r.md
  38. 0
      src/data/roadmaps/sql/content/creating-views@PcsGK4VBh0zNQIPZvNES4.md
  39. 0
      src/data/roadmaps/sql/content/cross-join@7ow6tiSSCnTpv_GYQU017.md
  40. 0
      src/data/roadmaps/sql/content/data-constraints@qBios3sZVhcJMpXmj9f7B.md
  41. 0
      src/data/roadmaps/sql/content/data-definition-language-ddl@xPOeXK1EPBNG56vgfG-VV.md
  42. 0
      src/data/roadmaps/sql/content/data-integrity--security@R1ktDJpXOz0PTllAcBrdu.md
  43. 0
      src/data/roadmaps/sql/content/data-integrity-constraints@mBQ3Z8GlFcpIena3IB7D_.md
  44. 0
      src/data/roadmaps/sql/content/data-manipulation-language-dml@WMSXi-eez_hHGDM8kUdWz.md
  45. 0
      src/data/roadmaps/sql/content/data-types@tBzMDfCMh6MIagNaxCzin.md
  46. 0
      src/data/roadmaps/sql/content/date@Ivqo2wa-_NhGU3vGd0pUI.md
  47. 0
      src/data/roadmaps/sql/content/dateadd@1E1WdWOyqxbbdiIbw26dZ.md
  48. 0
      src/data/roadmaps/sql/content/datepart@BJ4fQvagTO0B5UtXblyx8.md
  49. 0
      src/data/roadmaps/sql/content/db-security-best-practices@vhBZqqmUcEon6-Vwvla4q.md
  50. 0
      src/data/roadmaps/sql/content/delete@ddtVaA4Ls6qRj-7OtTSIH.md
  51. 0
      src/data/roadmaps/sql/content/delete@zWnvuHJLHr03PWkrW1wZZ.md
  52. 0
      src/data/roadmaps/sql/content/dense_rank@QM0ltgPu8lLLYc2MsTLj-.md
  53. 0
      src/data/roadmaps/sql/content/drop-table@YzJ6QmY2arMfRzMAPaI0T.md
  54. 0
      src/data/roadmaps/sql/content/dropping-views@MIOuWWcCjLAmgzog2DBC3.md
  55. 0
      src/data/roadmaps/sql/content/dynamic-sql@z5Sf0VU14ZCQ80kL1qOqc.md
  56. 0
      src/data/roadmaps/sql/content/floor@o2SH4iQn1Ap2yDZ7cVYLO.md
  57. 0
      src/data/roadmaps/sql/content/foreign-key@DHz6sRLYhFeCbAcNJS8hm.md
  58. 0
      src/data/roadmaps/sql/content/from@N1Racr3ZpU320gS545We8.md
  59. 0
      src/data/roadmaps/sql/content/full-outer-join@aS5zCyJRA779yHF0G2pje.md
  60. 0
      src/data/roadmaps/sql/content/grant-and-revoke@03qMopxzjx_-dZbYw9b7J.md
  61. 0
      src/data/roadmaps/sql/content/group-by@14TKE6KhrH1yFtHcSZSXq.md
  62. 0
      src/data/roadmaps/sql/content/group-by@Zw8IHfCCMSxmVjx5Ho5ff.md
  63. 0
      src/data/roadmaps/sql/content/having@HhICJpCK5__b-itUoEBES.md
  64. 0
      src/data/roadmaps/sql/content/having@ytwCkSMTiTuemE0KVfAfy.md
  65. 1
      src/data/roadmaps/sql/content/index.md
  66. 0
      src/data/roadmaps/sql/content/indexes@LcljR70T-OnzSrJJDqOWf.md
  67. 0
      src/data/roadmaps/sql/content/inner-join@aaua13CkTxLOYXr8cAgPm.md
  68. 0
      src/data/roadmaps/sql/content/insert@-Hew0y53ziZK3epQnGA0O.md
  69. 0
      src/data/roadmaps/sql/content/insert@mPj6BiK5FKKkIQ9WsWEo6.md
  70. 0
      src/data/roadmaps/sql/content/join-queries@8V6yw7kLaow-VVcv_K_pL.md
  71. 0
      src/data/roadmaps/sql/content/joins@4UQQYbjzwVxZOAxBuXKQS.md
  72. 0
      src/data/roadmaps/sql/content/lag@BcXdxY6bld5c0YNFSKkh-.md
  73. 0
      src/data/roadmaps/sql/content/lead@aJJjaGunRrwyh9MjQfJt-.md
  74. 0
      src/data/roadmaps/sql/content/learn-the-basics@nhUKKWyBH80nyKfGT8ErC.md
  75. 0
      src/data/roadmaps/sql/content/left-join@X9cJJ8zLZCF2cOoqxwFfY.md
  76. 0
      src/data/roadmaps/sql/content/length@RH8DLiQpDUWqw3U1522q5.md
  77. 0
      src/data/roadmaps/sql/content/lower@knTG6pAq2mYP24WMa29xI.md
  78. 0
      src/data/roadmaps/sql/content/managing-indexes@NtxGd6Vx-REBclry7lZuE.md
  79. 0
      src/data/roadmaps/sql/content/max@YqDJq3fPxUZlwsdq0kJg7.md
  80. 0
      src/data/roadmaps/sql/content/min@bFEYMlqPZtTUYtDQxqHzT.md
  81. 0
      src/data/roadmaps/sql/content/mod@OUw--8zEq6lk5-6oySVHe.md
  82. 0
      src/data/roadmaps/sql/content/modifying-views@3eE-l-P93nOXoWfLr8PSW.md
  83. 0
      src/data/roadmaps/sql/content/nested-subqueries@xkPJ2MYiXmzC4yqQWyB_7.md
  84. 0
      src/data/roadmaps/sql/content/not-null@M4M_-vjM9GNy0NmXZneDA.md
  85. 0
      src/data/roadmaps/sql/content/nullif@KI6vngoYcHsnpIk8ErhhS.md
  86. 0
      src/data/roadmaps/sql/content/operators@ffwniprGJHZzJ7t3lQcXz.md
  87. 0
      src/data/roadmaps/sql/content/optimizing-joins@C0dhS6uLf4TUSfvcWyXhv.md
  88. 0
      src/data/roadmaps/sql/content/order-by@NfCiSPrL4upMssukcw3Kh.md
  89. 0
      src/data/roadmaps/sql/content/performance-optimization@4rqCPpTb0dAgpheBKshRG.md
  90. 0
      src/data/roadmaps/sql/content/pivot--unpivot-operations@nwFaz9i-1s0WVrVaFsoqb.md
  91. 0
      src/data/roadmaps/sql/content/primary-key@Jlwmyq6CUQeDAlL4dazOP.md
  92. 0
      src/data/roadmaps/sql/content/query-analysis-techniques@C6P69YiFdS-ioPXMNfX07.md
  93. 0
      src/data/roadmaps/sql/content/query-optimization@Ps9Yv2s-bKvEegGAbPsiA.md
  94. 0
      src/data/roadmaps/sql/content/rank@cucCPw3KfetAP2OMFUs0X.md
  95. 0
      src/data/roadmaps/sql/content/rdbms-benefits-and-limitations@fNTb9y3zs1HPYclAmu_Wv.md
  96. 0
      src/data/roadmaps/sql/content/recursive-queries@TjgwabhEtaSoYMLNr6q9l.md
  97. 0
      src/data/roadmaps/sql/content/reducing-subqueries@UVTgbZrqpbYl1bQvQejcF.md
  98. 0
      src/data/roadmaps/sql/content/replace@VNbb3YPc0FtrROylRns8h.md
  99. 0
      src/data/roadmaps/sql/content/right-join@shpgZkh1CLqUwjOaRtAFy.md
  100. 0
      src/data/roadmaps/sql/content/rollback@xbD67KVlt3UhHpKh8HLx8.md
  101. Some files were not shown because too many files have changed in this diff Show More

@ -91,7 +91,7 @@ export function EditorRoadmap(props: EditorRoadmapProps) {
: undefined : undefined
} }
className={ className={
'flex aspect-[var(--aspect-ratio)] w-full flex-col justify-center' 'mt-5 flex aspect-[var(--aspect-ratio)] w-full flex-col justify-center'
} }
> >
<EditorRoadmapRenderer <EditorRoadmapRenderer

@ -7,7 +7,7 @@ seo:
title: 'DevOps vs SRE: Key Differences Explained' title: 'DevOps vs SRE: Key Differences Explained'
description: 'DevOps vs SRE: Discover which role suits your career best. Learn key differences, skills required, and career prospects in our detailed guide.' description: 'DevOps vs SRE: Discover which role suits your career best. Learn key differences, skills required, and career prospects in our detailed guide.'
ogImageUrl: 'https://assets.roadmap.sh/guest/devops-vs-sre1-pfhzy.jpg' ogImageUrl: 'https://assets.roadmap.sh/guest/devops-vs-sre1-pfhzy.jpg'
isNew: true isNew: false
type: 'textual' type: 'textual'
date: 2024-06-13 date: 2024-06-13
sitemap: sitemap:

@ -7,7 +7,7 @@ seo:
title: '12 In-Demand Front End Developer Skills to Master' title: '12 In-Demand Front End Developer Skills to Master'
description: 'Master these 12 in-demand front end developer skills and become a standout candidate in the web development field.' description: 'Master these 12 in-demand front end developer skills and become a standout candidate in the web development field.'
ogImageUrl: 'https://assets.roadmap.sh/guest/frontend-developer-skills-zdpyd.jpg' ogImageUrl: 'https://assets.roadmap.sh/guest/frontend-developer-skills-zdpyd.jpg'
isNew: true isNew: false
type: 'textual' type: 'textual'
date: 2024-07-04 date: 2024-07-04
sitemap: sitemap:

@ -7,7 +7,7 @@ seo:
title: '8 In-Demand Full Stack Developer Skills to Master' title: '8 In-Demand Full Stack Developer Skills to Master'
description: 'Master these 8 in-demand full stack developer skills and become a standout candidate for your next job application.' description: 'Master these 8 in-demand full stack developer skills and become a standout candidate for your next job application.'
ogImageUrl: 'https://assets.roadmap.sh/guest/full-stack-developer-skills-abb38.jpg' ogImageUrl: 'https://assets.roadmap.sh/guest/full-stack-developer-skills-abb38.jpg'
isNew: true isNew: false
type: 'textual' type: 'textual'
date: 2024-07-05 date: 2024-07-05
sitemap: sitemap:

@ -7,7 +7,7 @@ seo:
title: 'How to become a DevOps Engineer in @currentYear@' title: 'How to become a DevOps Engineer in @currentYear@'
description: 'Want to become a DevOps engineer? Our @currentYear@ guide covers skills, certifications, and expert career advice. Start your journey today!' description: 'Want to become a DevOps engineer? Our @currentYear@ guide covers skills, certifications, and expert career advice. Start your journey today!'
ogImageUrl: 'https://assets.roadmap.sh/guest/become-devops-engineer-4x2p7.jpg' ogImageUrl: 'https://assets.roadmap.sh/guest/become-devops-engineer-4x2p7.jpg'
isNew: true isNew: false
type: 'textual' type: 'textual'
date: 2024-06-11 date: 2024-06-11
sitemap: sitemap:

@ -1,54 +0,0 @@
# SELECT
The `SELECT` statement is used in SQL to pick out specific data from a database. In other words, it is used to select from the database what you would like to display. The syntax for the `SELECT` statement is fairly straightforward:
```sql
SELECT column(s)
FROM table
WHERE condition;
```
- `column(s)`: Enter the name(s) of the column(s) that you want to display.
- `table`: The name of the table from where you want to retrieve data.
- `WHERE`: Optional. This is a filter to display only the rows where this condition is true.
For instance, if you wanted to select all data from the "Customers" table, your query would look like this:
```sql
SELECT *
FROM Customers;
```
In the above code, the asterisk `*` denotes "all". This will retrieve all of the data in the "Customers" table.
If you want to select only the "FirstName" and "LastName" columns from the "Customers" table, your query would look like this:
```sql
SELECT FirstName, LastName
FROM Customers;
```
You can also filter using the `WHERE` clause. For example, selecting only the customers who are from "Germany":
```sql
SELECT *
FROM Customers
WHERE Country='Germany';
```
Finally, you can also sort the results using the `ORDER BY` keyword:
```sql
SELECT *
FROM Customers
ORDER BY Country;
```
This will sort the output in ascending order by the Country column. To sort in descending order, you would add the `DESC` keyword:
```sql
SELECT *
FROM Customers
ORDER BY Country DESC;
```
These are the very basics of the `SELECT` statement in SQL, which is a vital part of working with databases.

@ -1,37 +0,0 @@
# INSERT
The `INSERT` statement in SQL is used to add new rows of data to a table in the database. There are three forms of the `INSERT` statement: `INSERT INTO` values, `INSERT INTO` set, and `INSERT INTO` select.
## `INSERT INTO` values
The basic syntax for `INSERT INTO` values:
```sql
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
```
This form of the `INSERT` statement specifies both the column names and the values to be inserted.
## `INSERT INTO` set
In this form, you're able to insert data using the `SET` keyword. Here, you specify each column you want to insert data into, and then the data for that column.
```sql
INSERT INTO table_name
SET column1 = value1, column2 = value2, ...;
```
## `INSERT INTO` select
The `INSERT INTO SELECT` statement is used to copy data from one table and insert it into another table. Or, to insert data into specific columns from another table.
```sql
INSERT INTO table_name1 (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
FROM table_name2
WHERE condition;
```
In all cases, if you're inserting data into a table where some columns have default values, you don't need to specify those columns in your `INSERT INTO` statement.
Note: Be careful when inserting data into a database as SQL does not have a confirm command. So once you execute the insert statement, the records are inserted, and you can't undo the operation.

@ -1,45 +0,0 @@
# UPDATE
The SQL `UPDATE` statement is used to modify the existing data in a database. This statement is very useful when you need to change the values assigned to specific fields in an existing row or set of rows.
The general syntax for the UPDATE statement is as follows:
```sql
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
```
- `table_name`: The name of the table where an update will be performed.
- `SET`: This clause specifies the column name and the new value that it should be updated to.
- `column1, column2, ...`: The column names in the table.
- `value1, value2, ...`: The new values that you want to record into the database.
- `WHERE`: This clause specifies the conditions that identify which row(s) to update.
## Example Usage
Here's an example that might provide some clarity. For an imaginary `Employees` table:
| EmployeeID | Name | Position | Salary |
|------------|---------|----------|--------|
| 1 | Jane | Manager | 50000 |
| 2 | John | Clerk | 30000 |
| 3 | Bob | Engineer | 40000 |
If you want to increase Bob's salary by $5000, you would use:
```sql
UPDATE Employees
SET Salary = 45000
WHERE EmployeeID = 3;
```
This would permanently change the data in the `Employees` table:
| EmployeeID | Name | Position | Salary |
|------------|---------|----------|--------|
| 1 | Jane | Manager | 50000 |
| 2 | John | Clerk | 30000 |
| 3 | Bob | Engineer | 45000 |
Always be careful with the `UPDATE` statement; if you forget the `WHERE` clause, you will update all the rows in the table.

@ -1,30 +0,0 @@
# DELETE
The `DELETE` statement in SQL helps you remove existing records from a database. However, keep in mind, it is a destructive operation and may permanently erase data from your database.
With the `DELETE` statement, you can perform the following:
1. **Delete All Rows:**
The `DELETE` statement without a `WHERE` clause deletes all rows in a table. This operation is irreversible.
Example:
```sql
DELETE FROM table_name;
```
This SQL statement deletes all the records from `table_name`.
2. **Delete Specific Rows:**
When combined with the `WHERE` clause, the `DELETE` SQL statement erases specific rows that meet the condition.
Example:
```sql
DELETE FROM table_name WHERE condition;
```
This instance of the `DELETE` statement deletes records from `table_name` the place where the given `condition` matches.
It's crucial to use `DELETE` cautiously because it has the potential to either erase certain important rows or entirely empty the table.
*Note: The deletion made by the "DELETE" statement is permanent and cannot be undone. Always ensure to have a backup before running a DELETE query, especially when it is on a production database.*

@ -1,73 +0,0 @@
# SELECT
`SELECT` is one of the most widely used commands in SQL. This command is used to select data from a database. The data returned is stored in a results table, also called the result-set.
## Syntax
The simplest way to use the `SELECT` statement is to return all columns from a table. This can be done with the following syntax:
```sql
SELECT * FROM table_name;
```
This will return all fields (columns) of all records (rows) from the table.
If you want to select just certain columns, you can specify them by name, separated by commas:
```sql
SELECT column_name1, column_name2 FROM table_name;
```
## SELECT DISTINCT
The `SELECT DISTINCT` statement is used to return only unique values in the output. It can be used to eliminate duplicate values in the returned data.
```sql
SELECT DISTINCT column_name FROM table_name;
```
## WHERE Clause
The `WHERE` clause is used to filter records. The `WHERE` clause is used to extract only those records that fulfill a specified condition.
```sql
SELECT column_name FROM table_name WHERE condition;
```
## ORDER BY
The `ORDER BY` keyword is used to sort the result-set in ascending or descending order. The `ORDER BY` keyword sorts the records in ascending order by default. If you want to sort the records in descending order, you can use the `DESC` keyword.
```sql
SELECT column_name FROM table_name ORDER BY column_name ASC|DESC;
```
## Aggregate Functions
Aggregate functions in SQL are functions where the values of multiple rows are grouped together to form a single value of more significant meaning, such as a list, a set, or a sum. Some examples include `SUM()`, `COUNT()`, `MIN()`, `MAX()`, and `AVG()`.
```sql
SELECT COUNT(column_name) FROM table_name WHERE condition;
SELECT AVG(column_name) FROM table_name WHERE condition;
SELECT SUM(column_name) FROM table_name WHERE condition;
SELECT MIN(column_name) FROM table_name WHERE condition;
SELECT MAX(column_name) FROM table_name WHERE condition;
```
## GROUP BY
The `GROUP BY` statement is often used with aggregate functions (`COUNT`, `MAX`, `MIN`, `SUM`, `AVG`) to group the result-set by one or more columns.
```sql
SELECT column_name1, COUNT(column_name2) FROM table_name WHERE condition GROUP BY column_name1 ORDER BY COUNT(column_name2) DESC;
```
## HAVING Clause
The `HAVING` clause was added to SQL because the `WHERE` keyword could not be used with aggregate functions. It works like the WHERE clause but on grouped records.
```sql
SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name HAVING COUNT(column_name) > value;
```
The above are the most common uses of the `SELECT` keyword in SQL. There are other keywords and functions you can use to manipulate the data as well. These will give you a good start on using `SELECT` in your SQL queries.

@ -1,62 +0,0 @@
# Types of Sub Queries
Subqueries, sometimes referred to as inner queries or nested queries, are queries that are embedded within the clause of another SQL query. There are different types of SQL subqueries that are frequently used including Scalar, Row, Column, and Table subqueries.
## Scalar Subqueries
A scalar subquery is a query that returns exactly one column with a single value. This type of subquery can be used anywhere in your SQL where expressions are allowed.
Example:
```sql
SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE column_name operator
(SELECT column_name [, column_name ]
FROM table_name
WHERE condition);
```
## Row Subqueries
Row subqueries are used to return one or more rows to the outer SQL select query. However, the subquery returns multiple columns and rows, so it cannot be directly used where scalar expressions are used.
Example:
```sql
SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE (column_name [, column_name ])
IN (SELECT column_name [, column_name ]
FROM table_name
WHERE condition);
```
## Column Subqueries
Column Subqueries are used to return one or more columns to the outer SQL select query. They are used when the subquery is expected to return more than one column to the main query.
Example:
```sql
SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE (SELECT column_name [, column_name ]
FROM table_name
WHERE condition);
```
## Table Subqueries
Table subqueries are used in the FROM clause and return a table that can be used as a table-reference in an SQL statement. They come in handy when you want to perform operations such as joining multiple tables, union data from multiple sources, etc.
Example:
```sql
SELECT column_name [, column_name ]
FROM
(SELECT column_name [, column_name ]
FROM table1 [, table2 ])
WHERE condition;
```
Remember that not all SQL databases support all types of subqueries. Learning how and when to utilize each form is an essential aspect of constructing effective SQL queries.

@ -1,71 +0,0 @@
# Numeric
SQL numeric functions are used to perform operations on numeric data types such as integer, decimal, and float. They're fundamental in manipulating data in SQL commands and are commonly used in `SELECT`, `UPDATE`, `DELETE` and `INSERT` statements.
## Examples of SQL Numeric Functions:
1. **ABS() Function:** This function returns the absolute (positive) value of a number.
```sql
SELECT ABS(-243);
```
Output:
243
2. **Avg() Function:** This function returns the average value of a column.
```sql
SELECT AVG(price) FROM products;
```
3. **COUNT() Function:** This function returns the number of rows that matches a specified criterion.
```sql
SELECT COUNT(productID) FROM products;
```
4. **SUM() Function:** This function returns the total sum of a numeric column.
```sql
SELECT SUM(price) FROM products;
```
5. **MIN() & MAX() Functions:** MIN() function returns the smallest value of the selected column, and MAX() function returns the largest value of the selected column.
```sql
SELECT MIN(price) FROM products;
SELECT MAX(price) FROM products;
```
6. **ROUND() Function:** This function is used to round a numeric field to the nearest integer, you can, however, specify the number of decimals to be returned.
```sql
SELECT ROUND(price, 2) FROM products;
```
7. **CEILING() Function:** This function returns the smallest integer which is greater than, or equal to, the specified numeric expression.
```sql
SELECT CEILING(price) FROM products;
```
8. **FLOOR() Function:** This function returns the largest integer which is less than, or equal to, the specified numeric expression.
```sql
SELECT FLOOR(price) FROM products;
```
9. **SQRT() Function:** This function returns the square root of a number.
```sql
SELECT SQRT(price) FROM products;
```
10. **PI() Function:** This function returns the constant Pi.
```sql
SELECT PI();
```
These are just a few examples, SQL supports many more mathematical functions such as SIN, COS, TAN, COT, POWER, etc. Understanding and using these SQL numeric functions allows you to perform complex operations on the numeric data in your SQL tables.

@ -1,91 +0,0 @@
# String Functions
In SQL, you can perform various operations on strings, including extracting a string, combining two or more strings, and converting a case of a string.
## CONCAT Function
The CONCAT function combines two or more strings into one string. The following is the syntax:
```sql
CONCAT(string1, string2, ...., string_n)
```
Example:
```sql
SELECT CONCAT('Hello ', 'World');
```
The output of the above SQL statement will be 'Hello World'.
## SUBSTRING Function
The SUBSTRING function extracts a string from a given string. The syntax looks as follows:
```sql
SUBSTRING(string, start, length)
```
Example:
```sql
SELECT SUBSTRING('SQL Tutorial', 1, 3);
```
The output of the above query will be 'SQL'.
## LENGTH Function
The LENGTH function returns the length of a string. The syntax is:
```sql
LENGTH(string)
```
Example:
```sql
SELECT LENGTH('Hello World');
```
The output of the above SQL statement will be 11.
## UPPER and LOWER Function
The UPPER function converts all the letters in a string to uppercase, whereas the LOWER function to lowercase.
Syntax:
```sql
UPPER(string)
LOWER(string)
```
Examples:
```sql
SELECT UPPER('Hello World');
SELECT LOWER('Hello World');
```
The output of the above SQL statements will be 'HELLO WORLD' and 'hello world' respectively.
## TRIM Function
The TRIM function removes leading and trailing spaces of a string. You can also remove other specified characters.
Syntax:
```sql
TRIM([LEADING|TRAILING|BOTH] [removal_string] FROM original_string)
```
Example:
```sql
SELECT TRIM(' Hello World ');
SELECT TRIM('h' FROM 'hello');
```
The output of the first query will be 'Hello World' and that of the second query will be 'ello'.

@ -1,67 +0,0 @@
# Conditional
In SQL, Conditional expressions can be used in the SELECT statement, WHERE clause, and ORDER BY clause to evaluate multiple conditions. These are SQL's version of the common if…then…else statement in other programming languages.
There are two kinds of conditional expressions in SQL:
1. **CASE** expression
The `CASE` expression is a flow-control statement that allows you to add if-else logic to a query. It comes in two forms: simple and searched.
Here is an example of a simple `CASE` expression:
```sql
SELECT OrderID, Quantity,
CASE
WHEN Quantity > 30 THEN 'Over 30'
ELSE 'Under 30'
END AS QuantityText
FROM OrderDetails;
```
A searched `CASE` statement:
```sql
SELECT FirstName, City,
CASE
WHEN City = 'Berlin' THEN 'Germany'
WHEN City = 'Madrid' THEN 'Spain'
ELSE 'Unknown'
END AS Country
FROM Customers;
```
2. **COALESCE** expression
The `COALESCE` function returns the first non-null value in a list. It takes a comma-separated list of values and returns the first value that is not null.
An example of a `COALESCE` statement:
```sql
SELECT ProductName,
COALESCE(UnitsOnOrder, 0) As UnitsOnOrder,
COALESCE(UnitsInStock, 0) As UnitsInStock,
FROM Products;
```
3. **NULLIF** expression
`NULLIF` returns null if the two given expressions are equal.
Example of using `NULLIF`:
```sql
SELECT NULLIF(5,5) AS Same,
NULLIF(5,7) AS Different;
```
4. **IIF** expression
`IIF` function returns value_true if the condition is TRUE, or value_false if the condition is FALSE.
Example of using `IIF`:
```sql
SELECT IIF (1>0, 'One is greater than zero', 'One is not greater than zero');
```
These are essential constructs that can greatly increase the flexibility and functionality of your SQL code, particularly when dealing with elaborate conditions and specific data selections.

@ -1,47 +0,0 @@
# Date and Time
In SQL, the `DateTime` data type is used to work with dates and times. SQL Server comes with numerous functions for processing dates and times. Some of these include `GETDATE()`, `DATEDIFF()`, `DATEADD()`, `CONVERT()`, and so forth.
## GETDATE()
`GETDATE()` returns the current date and time as a DateTime datatype. It does not require any arguments.
```sql
SELECT GETDATE() AS CurrentDateTime;
```
## DATEDIFF()
`DATEDIFF()` returns the difference between two date values based on the unit of time you want to use. The syntax is `DATEDIFF(datepart, startdate, enddate)`.
```sql
SELECT DATEDIFF(day, '2022-01-01', '2022-01-15') AS DiffInDays;
```
## DATEADD()
`DATEADD()` adds or subtracts a specified time interval from a date. Its syntax is `DATEADD(datepart, number, date)`.
```sql
SELECT DATEADD(year, 1, '2022-01-01') AS NewDate;
```
## CONVERT()
`CONVERT()` is used to convert from one data type to another, and it is commonly used to format DateTime values. Its syntax is `CONVERT(data_type(length), expression, style)`.
```sql
SELECT CONVERT(VARCHAR(19), GETDATE()) AS FormattedDateTime;
```
Remember to replace `date` with your date in above queries.
## DateTime Format
By using appropriate format codes, SQL allows us to present dates and times in various formats.
```sql
SELECT FORMAT(GETDATE(), 'MM/dd/yyyy') AS DateFormatted;
```
Also, by using specific column names instead of `GETDATE()`, the same patterns can be applied to DateTime values in your data.
Note: All dates are stored as numeric values under the hood, with the integer portion representing the date and the decimal portion representing the time. Also, different database systems may use slightly different functions for handling dates and times, so be sure to check the documentation for your specific DBMS.

@ -1,65 +0,0 @@
# Query Optimization Techniques
SQL Query Optimization is a crucial aspect of database management, aiming to maximize the speed and efficiency of SQL queries. Optimization takes into consideration a variety of factors like the query structure, data distribution, hardware specifics, and data-indexing.
## 1. Utilize Indexes:
Indexes enable the database engine to quickly find records just like an index in a book helps facilitate faster information location.
```sql
CREATE INDEX index_name
ON table_name (column1, column2, ...);
```
## 2. Use Joins instead of Multiple Queries:
Multiple separate queries to retrieve data can be merged into a single JOIN query for a more efficient process.
```sql
SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;
```
## 3. Limit the Number of Rows:
Only request the number of rows you need. The `LIMIT` clause reduces the number of records returned by a SQL statement.
```sql
SELECT column FROM table
ORDER BY column DESC
LIMIT 10;
```
## 4. Avoid SELECT * :
Select only the columns you need to prevent the overhead of loading unnecessary data.
```sql
SELECT column1, column2
FROM table;
```
## 5. Use WHERE instead of HAVING for Filtering:
`WHERE` clause filters records before grouping while `HAVING` filters after. Utilizing `WHERE` can optimize the query performance.
```sql
SELECT column1, COUNT(column2)
FROM table
WHERE condition
GROUP BY column1;
```
## 6. If Possible Avoid the use of Subqueries:
A subquery is a SQL query enclosed in a larger SQL query. Often they may result in complex and less optimized queries.
```sql
SELECT column_name(s)
FROM table1
WHERE column_name operator
(SELECT column_name(s) from table2);
```
Remember there's no universal optimal solution, each SQL query will have its specific optimization strategies.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save