Skip to content

Commit d2518b2

Browse files
authored
Add files via upload
1 parent 4e3f015 commit d2518b2

64 files changed

Lines changed: 2954 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

abs.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!-- SECCIÓN ABS NUMERIC FUNCTION -->
2+
<div id="abs-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL ABS() Function</h1>
7+
8+
<p>The <strong>ABS()</strong> function returns the absolute (positive) value of a number.</p>
9+
10+
<h2>Syntax</h2>
11+
<pre><code class="language-sql">ABS(number)</code></pre>
12+
13+
<h2>Parameter Values</h2>
14+
<ul>
15+
<li><strong>number</strong>: Required. A numeric value.</li>
16+
</ul>
17+
18+
<h2>ABS() Example</h2>
19+
<p>The following SQL statement returns the absolute value of <strong>-362.3</strong>:</p>
20+
21+
<pre><code class="language-sql">SELECT ABS(-362.3);</code></pre>
22+
23+
</div>
24+
</div>
25+
</div>

aliases.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!-- SECCIÓN ALIASES -->
2+
<div id="aliases-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL Aliases</h1>
7+
8+
<p>SQL aliases are used to give a table, or a column in a table, a temporary name. Aliases are often used to
9+
make column names more readable.</p>
10+
<p>An alias only exists for the duration of that query. An alias is created with the <strong>AS</strong>
11+
keyword. Depending on the SQL dialect, the AS keyword may be optional.</p>
12+
13+
<h2>Alias Column Syntax</h2>
14+
<pre><code class="language-sql">SELECT column_name AS alias_name
15+
FROM table_name;</code></pre>
16+
17+
<h2>Alias Table Syntax</h2>
18+
<pre><code class="language-sql">SELECT column_name(s)
19+
FROM table_name AS alias_name;</code></pre>
20+
21+
<h2>Alias for Columns Examples</h2>
22+
<p>The following SQL statement creates two aliases, one for the <code>weight</code> column and one for the
23+
<code>height</code> column:</p>
24+
<pre><code class="language-sql">SELECT avg(weight) AS average_weight,
25+
avg(height) AS average_height
26+
FROM patients;</code></pre>
27+
28+
<h2>Alias for Tables Example</h2>
29+
<p>The following SQL renames the <code>admissions</code> table as 'a' and the <code>patients</code> table as
30+
'p':</p>
31+
<pre><code class="language-sql">SELECT *
32+
FROM patients AS p
33+
JOIN admissions AS a ON a.patient_id = p.patient_id;</code></pre>
34+
</div>
35+
</div>
36+
</div>

alter-table.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!-- SECCIÓN ALTER TABLE -->
2+
<div id="alter-table-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL ALTER TABLE Statement</h1>
7+
8+
<p>The <strong>ALTER TABLE</strong> statement is used to add, delete, or modify columns in an existing
9+
table.
10+
It is also used to add or drop various constraints on an existing table.</p>
11+
<p><strong>Note:</strong> ALTER/MODIFY COLUMN syntax is not supported in this tutorial.</p>
12+
13+
<h2>ALTER TABLE - ADD Column Syntax</h2>
14+
<pre><code class="language-sql">ALTER TABLE table_name
15+
ADD column_name datatype;</code></pre>
16+
17+
<p>Example: Add an "email" column to the "patients" table:</p>
18+
<pre><code class="language-sql">ALTER TABLE patients
19+
ADD email varchar(255);
20+
21+
SELECT patient_id, email FROM patients;</code></pre>
22+
23+
<h2>ALTER TABLE - DROP COLUMN Syntax</h2>
24+
<p>To delete a column in a table:</p>
25+
<pre><code class="language-sql">ALTER TABLE table_name
26+
DROP COLUMN column_name;</code></pre>
27+
28+
<p>Example: Delete the "last_name" column from the "patients" table:</p>
29+
<pre><code class="language-sql">ALTER TABLE patients
30+
DROP COLUMN last_name;
31+
32+
SELECT * FROM patients;</code></pre>
33+
34+
<h2>ALTER TABLE - ALTER/MODIFY COLUMN Syntax</h2>
35+
<p>To change the data type of a column in a table:</p>
36+
<pre><code class="language-sql">-- SQL Server / MS Access
37+
ALTER TABLE table_name
38+
ALTER COLUMN column_name datatype;
39+
40+
-- MySQL / Oracle (prior to 10G)
41+
ALTER TABLE table_name
42+
MODIFY COLUMN column_name datatype;
43+
44+
-- Oracle 10G and later
45+
ALTER TABLE table_name
46+
MODIFY column_name datatype;</code></pre>
47+
</div>
48+
</div>
49+
</div>

any-all.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!-- SECCIÓN ANY / ALL -->
2+
<div id="anyall-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL ANY and ALL Operators</h1>
7+
8+
<p>The ANY and ALL operators allow you to perform a comparison between a single column value and a range of
9+
other values.</p>
10+
<p><strong>DISCLAIMER:</strong> This tool does not support the Any/All Operator.</p>
11+
12+
<h2>The SQL ANY Operator</h2>
13+
<p>The ANY operator:</p>
14+
<ul>
15+
<li>returns a boolean value as a result</li>
16+
<li>returns TRUE if ANY of the subquery values meet the condition</li>
17+
</ul>
18+
<p>ANY means that the condition will be true if the operation is true for any of the values in the range.
19+
</p>
20+
21+
<h3>ANY Syntax</h3>
22+
<pre><code class="language-sql">SELECT column_name(s)
23+
FROM table_name
24+
WHERE column_name operator ANY
25+
(SELECT column_name
26+
FROM table_name
27+
WHERE condition);</code></pre>
28+
29+
<h2>The SQL ALL Operator</h2>
30+
<p>The ALL operator:</p>
31+
<ul>
32+
<li>returns a boolean value as a result</li>
33+
<li>returns TRUE if ALL of the subquery values meet the condition</li>
34+
<li>is used with SELECT, WHERE and HAVING statements</li>
35+
</ul>
36+
<p>ALL means that the condition will be true only if the operation is true for all values in the range.</p>
37+
38+
<h3>ALL Syntax With SELECT</h3>
39+
<pre><code class="language-sql">SELECT ALL column_name(s)
40+
FROM table_name
41+
WHERE condition;</code></pre>
42+
43+
<h3>ALL Syntax With WHERE or HAVING</h3>
44+
<pre><code class="language-sql">SELECT column_name(s)
45+
FROM table_name
46+
WHERE column_name operator ALL
47+
(SELECT column_name
48+
FROM table_name
49+
WHERE condition);</code></pre>
50+
</div>
51+
</div>
52+
</div>

auto-increment.html

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!-- SECCIÓN AUTO-INCREMENT -->
2+
<div id="auto-increment-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>AUTO INCREMENT Field</h1>
7+
8+
<p>Auto-increment allows a unique number to be generated automatically when a new record is inserted into a
9+
table.
10+
Often this is the primary key field that is created automatically for each new record.</p>
11+
12+
<h2>MySQL Syntax</h2>
13+
<pre><code class="language-sql">CREATE TABLE Persons (
14+
Personid int NOT NULL AUTO_INCREMENT,
15+
LastName varchar(255) NOT NULL,
16+
FirstName varchar(255),
17+
Age int,
18+
PRIMARY KEY (Personid)
19+
);
20+
21+
-- Start AUTO_INCREMENT with another value
22+
ALTER TABLE Persons AUTO_INCREMENT=100;
23+
24+
-- Insert without specifying Personid
25+
INSERT INTO Persons (FirstName, LastName)
26+
VALUES ('Lars','Monsen');</code></pre>
27+
28+
<h2>SQL Server Syntax</h2>
29+
<pre><code class="language-sql">CREATE TABLE Persons (
30+
Personid int IDENTITY(1,1) PRIMARY KEY,
31+
LastName varchar(255) NOT NULL,
32+
FirstName varchar(255),
33+
Age int
34+
);
35+
36+
-- Tip: Start at 10, increment by 5
37+
-- Personid int IDENTITY(10,5) PRIMARY KEY
38+
39+
INSERT INTO Persons (FirstName, LastName)
40+
VALUES ('Lars','Monsen');</code></pre>
41+
42+
<h2>MS Access Syntax</h2>
43+
<pre><code class="language-sql">CREATE TABLE Persons (
44+
Personid AUTOINCREMENT PRIMARY KEY,
45+
LastName varchar(255) NOT NULL,
46+
FirstName varchar(255),
47+
Age int
48+
);
49+
50+
-- Tip: Start at 10, increment by 5
51+
-- AUTOINCREMENT(10,5)
52+
53+
INSERT INTO Persons (FirstName, LastName)
54+
VALUES ('Lars','Monsen');</code></pre>
55+
56+
<h2>Oracle Syntax</h2>
57+
<p>Oracle requires a sequence object to implement auto-increment:</p>
58+
<pre><code class="language-sql">-- Create sequence
59+
CREATE SEQUENCE seq_person
60+
MINVALUE 1
61+
START WITH 1
62+
INCREMENT BY 1
63+
CACHE 10;
64+
65+
-- Insert using nextval
66+
INSERT INTO Persons (Personid, FirstName, LastName)
67+
VALUES (seq_person.nextval, 'Lars', 'Monsen');</code></pre>
68+
</div>
69+
</div>
70+
</div>

avg.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- SECCIÓN AVG() -->
2+
<div id="avg-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL AVG() Function</h1>
7+
8+
<p>The <strong>AVG()</strong> function returns the average value of a numeric column.</p>
9+
10+
<h2>AVG() Syntax</h2>
11+
<pre><code class="language-sql">SELECT AVG(column_name)
12+
FROM table_name
13+
WHERE condition;</code></pre>
14+
15+
<h2>AVG() Example</h2>
16+
<p>The following SQL statement finds the average weight of patients:</p>
17+
<pre><code class="language-sql">SELECT AVG(weight) FROM patients;</code></pre>
18+
</div>
19+
</div>
20+
</div>

between.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- SECCIÓN BETWEEN -->
2+
<div id="between-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL BETWEEN Operator</h1>
7+
8+
<p>The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.</p>
9+
<p>The BETWEEN operator is inclusive: begin and end values are included.</p>
10+
11+
<h2>BETWEEN Syntax</h2>
12+
<pre><code class="language-sql">SELECT column_name(s)
13+
FROM table_name
14+
WHERE column_name BETWEEN value1 AND value2;</code></pre>
15+
16+
<h2>BETWEEN Example</h2>
17+
<p>The following SQL statement selects all patients with a weight between 100 and 120:</p>
18+
19+
<pre><code class="language-sql">SELECT * FROM patients
20+
WHERE weight BETWEEN 100 AND 120;</code></pre>
21+
22+
<h2>NOT BETWEEN Example</h2>
23+
<p>To display the products outside the range of the previous example, use NOT BETWEEN:</p>
24+
25+
<pre><code class="language-sql">SELECT * FROM patients
26+
WHERE weight NOT BETWEEN 100 AND 120;</code></pre>
27+
28+
<h2>BETWEEN with IN Example</h2>
29+
<p>The following SQL statement selects all patients with a weight between 100 and 120. In addition; do not
30+
show patients located in 'ON', 'SK', or 'AB':</p>
31+
32+
<pre><code class="language-sql">SELECT * FROM patients
33+
WHERE weight BETWEEN 100 AND 120
34+
AND province_id NOT IN ('ON', 'SK', 'AB');</code></pre>
35+
36+
<h2>BETWEEN with Text</h2>
37+
<p>Text is compared based on the ASCII value of the text. For example, 'c'(99) is between 'a'(97) and
38+
'e'(101) but 'C'(67) is not between 'a'(97) and 'e'(101).</p>
39+
40+
<p>The following SQL statement selects all patients with their first_name between 'Alex' and 'Ben':</p>
41+
42+
<pre><code class="language-sql">SELECT * FROM patients
43+
WHERE first_name BETWEEN 'Alex' AND 'Ben';</code></pre>
44+
</div>
45+
</div>
46+
</div>

case.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!-- SECCIÓN CASE -->
2+
<div id="case-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL CASE Statement</h1>
7+
8+
<p>The CASE statement goes through conditions and returns a value when the first condition is met (like an
9+
if-then-else statement). Once a condition is true, it will stop reading and return the result. If no
10+
conditions are true, it returns the value in the ELSE clause.</p>
11+
<p>If there is no ELSE part and no conditions are true, it returns NULL.</p>
12+
13+
<h2>CASE Syntax</h2>
14+
<pre><code class="language-sql">CASE
15+
WHEN condition1 THEN result1
16+
WHEN condition2 THEN result2
17+
WHEN conditionN THEN resultN
18+
ELSE result
19+
END;</code></pre>
20+
21+
<h2>SQL CASE Examples</h2>
22+
<p>The following SQL goes through conditions and returns a value when the first condition is met:</p>
23+
<pre><code class="language-sql">SELECT patient_id, height,
24+
CASE
25+
WHEN height > 175 THEN 'height is greater than 175'
26+
WHEN height = 175 THEN 'height is 175'
27+
ELSE 'height is under 175'
28+
END AS height_group
29+
FROM patients;</code></pre>
30+
31+
<h2>CASE in ORDER BY Example</h2>
32+
<p>The following SQL will order the patients by allergies. However, if allergies is NULL, then order by
33+
patient_id:</p>
34+
<pre><code class="language-sql">SELECT patient_id, first_name, allergies
35+
FROM patients
36+
ORDER BY
37+
(CASE
38+
WHEN allergies IS NULL THEN first_name
39+
ELSE allergies
40+
END);</code></pre>
41+
</div>
42+
</div>
43+
</div>

ceil.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!-- SECCIÓN CEIL NUMERIC FUNCTION -->
2+
<div id="ceil-section">
3+
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
4+
<div class="inner-modal">
5+
<div class="inner" style="padding: 0px;">
6+
<h1>SQL CEIL() Function</h1>
7+
8+
<p>The <strong>CEIL()</strong> function returns a number rounded up to the nearest integer.</p>
9+
10+
<h2>Syntax</h2>
11+
<pre><code class="language-sql">CEIL(number)</code></pre>
12+
13+
<h2>Parameter Values</h2>
14+
<ul>
15+
<li><strong>number</strong>: Required. The numeric value to round up.</li>
16+
</ul>
17+
18+
<h2>CEIL() Example</h2>
19+
<p>The following SQL statement rounds up <strong>25.1</strong> to <strong>26</strong>:</p>
20+
21+
<pre><code class="language-sql">SELECT CEIL(25.1);</code></pre>
22+
23+
</div>
24+
</div>
25+
</div>

0 commit comments

Comments
 (0)