SQL Cheat Sheet: Section 1
SQL Cheat Sheet: Section 1
Section 2
(Or DESC) -> returns the table name, data types, pk, fk, and null columns
DISTINCT Concatenation
Eliminate diplicate rows
SELECT DISTINCT <colum_name>
MULTIPLE ROW
many rows -> single
MAX: Highest value
DESC |Alias | other <colum> not called
MIN: Lowest value
multiple <colum>
AVG: Average value
Section 4
DUAL TABLE not directly related to database table
CONVERT
MONTH_BETWEEN (2 dates)
<convert> (<colum_name>) SYSDATE ADD_MONTH
LOWER -> to lower-case DATE FUNCTIONS NEXT_DAY (of specified)
UPPER -> to upper.case LAST_DAY (of the month)
ROUND, TRUNC
INTCAP -> first letter upper
CHARACTER MANIPULATION FUNCTIONS (+ alias)
NUMBER FUNCTIONS
ROUND -> round numbers
TRUNC -> terminate number
MOD -> finds the reminder (odd or even)
3 4
1 *
2
3
*YY -> this century
4 RR -> not this century
fx -> Requires exact matching between the character data and the format model.
Section 6 fm -> Returns a value with no leading or trailing blanks.
NATURAL JOIN -> 2 Tables, matches colums & rows with equal value and name. (diferent data type -> ERROR)
CROSS JOIN -> joins each row in one table to every row in the other table.
JOIN... ON (...)
JOIN ... USING (...) Adding 2 tables without matching columns
Could use non-equality operators
(Between... and)
Avoids natural join error
Should not have alias o table name in the statement
Both (using and on) could be used to join three tables or more