SQL CommandUse Case
CREATE DACreates a new database.
DROP DAT Deletes an existing database.
CREATE TACreates a new table in the database.
DROP TABLDeletes a table from the database.
ALTER TABModifies an existing table (add, drop columns, etc.).
RENAME TChanges the name of a table.
TRUNCATERemoves all records from a table, but keeps the structure.
COMMENTAdds comments to the data dictionary.
INSERT IN Inserts new records into a table.
SELECT Retrieves records from one or more tables.
UPDATE Modifies existing records in a table.
DELETE Removes records from a table.
WHERE Filters records based on condition.
AND Combines two or more conditions (all must be true).
OR Combines two or more conditions (at least one must be true).
NOT Reverses the meaning of a condition.
ORDER BY Sorts results by one or more columns.
GROUP BY Groups rows that have the same values.
HAVING Filters groups created by GROUP BY.
JOIN Combines rows from two or more tables.
INNER JOI Returns records with matching values in both tables.
LEFT JOIN Returns all records from left table and matched from right.
RIGHT JOINReturns all records from right table and matched from left.
FULL JOIN Returns all records when there is a match in either table.
CROSS JOI Returns the Cartesian product of two tables.
UNION Combines the result set of two or more SELECTs.
UNION ALLSame as UNION, but includes duplicates.
EXISTS Tests for the existence of any record.
IN Checks if value exists in a list.
BETWEEN Selects values within a given range.
LIKE Searches for a specified pattern.
IS NULL Tests for empty (null) values.
IS NOT NULTests for non-empty values.
DISTINCT Returns only distinct (different) values.
LIMIT Specifies the number of records to return.
OFFSET Specifies where to start returning records.
CASE Adds conditional logic to queries.
AS Renames a column or table with an alias.
VIEW Creates a virtual table based on the result set of a query.
INDEX Creates an index (search key).
PRIMARY KUniquely identifies each record in a table.
FOREIGN KUniquely identifies a record in another table.
CHECK Ensures that values in a column satisfy a specific condition.
DEFAULT Sets a default value for a column.
AUTO_INCAutomatically increases value for a column.
CONSTRAI Used to specify rules for data.
GRANT Gives privileges to users.
REVOKE Takes back privileges from users.
COMMIT Saves changes made by the transaction.
ROLLBACK Undoes changes made by the transaction.
SAVEPOINTSets a savepoint within a transaction.
TRANSACTStarts a transaction.
EXPLAIN Displays execution plan of a query.
DESCRIBE Describes structure of a table.
SHOW TABLists all tables in a database.
SHOW COLLists columns in a table.
NOW() Returns current date and time.
CURDATE()Returns current date.
CURTIME()Returns current time.
DATEDIFF()Returns the difference between two dates.
DATE_ADD(Adds a time/date interval to a date.
DATE_SUB(Subtracts a time/date interval from a date.
IFNULL() Returns alternative value if NULL.
COALESCE(Returns first non-null value.
SUBSTRINGExtracts substring from a string.
LENGTH() Returns length of a string.
CONCAT() Concatenates two or more strings.
ROUND() Rounds a number to specified decimals.
AVG() Returns average value.
COUNT() Returns number of rows.
MIN() Returns minimum value.
MAX() Returns maximum value.
SUM() Returns total sum.
ABS() Returns absolute value.
MOD() Returns remainder of division.
FLOOR() Rounds down to nearest integer.
CEIL() Rounds up to nearest integer.
RAND() Returns a random number.
UCASE() Converts to uppercase.
LCASE() Converts to lowercase.
REPLACE() Replaces occurrences of a string.
CAST() Converts a value from one type to another.
CONVERT()Converts a value to a different data type.
DATABASE(Returns the name of the current database.
USER() Returns the current database user.
CHAR_LENG Returns number of characters in string.
POSITION()Returns position of substring.
STRCMP() Compares two strings.
LOCATE() Returns position of substring in string.
REVERSE() Reverses a string.
BIN() Returns binary representation.
HEX() Returns hexadecimal representation.
IF() Returns value based on a condition.
GREATEST(Returns the largest value.
LEAST() Returns the smallest value.
FORMAT() Formats number to specified decimal places.
INSTR() Returns position of substring in string.
UUID() Generates a universally unique identifier.
SLEEP() Delays query for a specific time.
Excel Command
Use Case
SUM Adds numbers in a range. E.g., =SUM(A1:A10)
AVERAGE Calculates average of numbers. E.g., =AVERAGE(A1:A10)
IF Returns one value if condition is TRUE, another if FALSE. E.g., =IF(A1>10, "Yes", "No")
VLOOKUP Looks up a value in a table. E.g., =VLOOKUP(1001, A2:B10, 2, FALSE)
HLOOKUP Looks up a value in a row. E.g., =HLOOKUP("Q1", A1:D5, 2, FALSE)
INDEX Returns value at a given position. E.g., =INDEX(A1:C3, 2, 1)
MATCH Returns position of a value. E.g., =MATCH(50, A1:A10, 0)
COUNTA Counts non-empty cells. E.g., =COUNTA(A1:A10)
COUNT Counts numeric values. E.g., =COUNT(A1:A10)
COUNTIF Counts cells meeting a condition. E.g., =COUNTIF(A1:A10, ">10")
ISERROR Checks for an error. E.g., =ISERROR(A1/B1)
IFERROR Returns value if error, else result. E.g., =IFERROR(A1/B1, 0)
NOW Returns current date and time. E.g., =NOW()
TODAY Returns current date. E.g., =TODAY()
LEFT Returns left characters from a string. E.g., =LEFT(A1, 5)
RIGHT Returns right characters from a string. E.g., =RIGHT(A1, 3)
MID Returns a substring. E.g., =MID(A1, 2, 3)
LEN Returns length of text. E.g., =LEN(A1)
TRIM Removes extra spaces. E.g., =TRIM(A1)
CONCATENJoins strings. E.g., =CONCATENATE(A1, B1)
TEXT Formats a number/date. E.g., =TEXT(A1, "dd-mm-yyyy")
ROUND Rounds a number. E.g., =ROUND(A1, 2)
ROUNDUP Rounds up. E.g., =ROUNDUP(A1, 0)
ROUNDDORounds down. E.g., =ROUNDDOWN(A1, 0)
INT Rounds down to nearest integer. E.g., =INT(A1)
MOD Returns remainder. E.g., =MOD(A1, 3)
ABS Returns absolute value. E.g., =ABS(A1)
POWER Raises a number to a power. E.g., =POWER(2, 3)
SQRT Returns square root. E.g., =SQRT(A1)
RAND Returns a random number. E.g., =RAND()
RANDBETWReturns random number between values. E.g., =RANDBETWEEN(1, 100)
AND Returns TRUE if all conditions are TRUE. E.g., =AND(A1>10, B1<5)
OR Returns TRUE if any condition is TRUE. E.g., =OR(A1>10, B1<5)
NOT Reverses logic. E.g., =NOT(A1>10)
SEARCH Finds text position. E.g., =SEARCH("x", A1)
FIND Finds text position (case-sensitive). E.g., =FIND("X", A1)
REPLACE Replaces part of text. E.g., =REPLACE(A1, 1, 3, "ABC")
SUBSTITUTSubstitutes text. E.g., =SUBSTITUTE(A1, "old", "new")
UPPER Converts to uppercase. E.g., =UPPER(A1)
LOWER Converts to lowercase. E.g., =LOWER(A1)
PROPER Capitalizes each word. E.g., =PROPER(A1)
TEXTJOIN Joins text with delimiter. E.g., =TEXTJOIN(", ", TRUE, A1:A3)
UNIQUE Returns unique values. E.g., =UNIQUE(A1:A10)
FILTER Filters a range. E.g., =FILTER(A1:A10, A1:A10>5)
SORT Sorts a range. E.g., =SORT(A1:A10)
TRANSPOSChanges row to column. E.g., =TRANSPOSE(A1:B2)
SPLIT Splits text into array. E.g., =SPLIT(A1, ",")
CELL Returns info about a cell. E.g., =CELL("address", A1)
ROW Returns row number. E.g., =ROW(A1)
COLUMN Returns column number. E.g., =COLUMN(A1)
INDIRECT Returns reference from text. E.g., =INDIRECT("A1")
OFFSET Returns cell offset from reference. E.g., =OFFSET(A1, 2, 1)
HYPERLINKCreates clickable link. E.g., =HYPERLINK("http://...", "Click")