SQL Tutorial
Estimated reading: 4 minutes 79 views

๐Ÿงพ SQL References & Functions โ€“ A Handy Guide to SQL Keywords and Built-In Functions


๐Ÿงฒ Introduction โ€“ Why Learn SQL References and Functions?

SQL (Structured Query Language) is the foundation for managing and querying databases. But beyond just writing SELECT and INSERT statements, understanding SQL references, keywords, and functions empowers developers, analysts, and DBAs to write precise, powerful, and optimized queries.

Whether you’re working with MySQL, SQL Server, or MS Access, each platform offers a rich set of keywords and built-in functions that allow for advanced operations like string manipulation, date calculations, type conversions, and data aggregation.

๐ŸŽฏ In this guide, youโ€™ll learn:

  • Common SQL keywords used across all RDBMS
  • Popular built-in functions in MySQL and SQL Server
  • Specialized features in Microsoft Access

๐Ÿ“˜ Topics Covered in This Guide

๐Ÿ”ข Topic๐Ÿ”Ž Description
๐Ÿ“š SQL KeywordsCore commands used across all SQL operations
๐Ÿ”ง MySQL FunctionsCommon MySQL functions for string, math, date, and aggregation
๐Ÿ› ๏ธ SQL Server FunctionsPowerful T-SQL functions for advanced data processing
๐Ÿ“‚ MS Access FunctionsBuilt-in functions tailored for Microsoft Access users

1. ๐Ÿ“š SQL Keywords

SQL keywords are reserved words that define the structure and logic of SQL queries. They are case-insensitive, though capitalized for readability.

โœ… Common SQL Keywords:

KeywordPurpose
SELECTRetrieve data from one or more tables
INSERTAdd new data into a table
UPDATEModify existing records
DELETERemove records
CREATECreate database objects like tables
DROPDelete database objects
ALTERModify table structures
WHEREFilter records
ORDER BYSort results
GROUP BYGroup records for aggregation
HAVINGFilter grouped records
JOINCombine rows from multiple tables
DISTINCTRemove duplicate rows
LIMIT / TOPRestrict the number of rows returned

2. ๐Ÿ”ง MySQL Functions

MySQL offers numerous built-in functions across different categories:

๐Ÿ”ค String Functions

FunctionDescription
CONCAT(a, b)Combine strings a and b
UPPER(str)Convert string to uppercase
LOWER(str)Convert string to lowercase
SUBSTRING(str, start, len)Extract part of a string

๐Ÿ“… Date Functions

FunctionDescription
NOW()Current date and time
CURDATE()Current date
DATE_ADD(date, INTERVAL n DAY)Add days to a date
DATEDIFF(date1, date2)Difference between two dates

โž• Math Functions

FunctionDescription
ROUND(num, decimals)Round number to decimals
FLOOR(num)Round down
CEIL(num)Round up
ABS(num)Absolute value

๐Ÿ“Š Aggregate Functions

FunctionDescription
COUNT(*)Count records
SUM(col)Total of column
AVG(col)Average value
MAX(col)Maximum value
MIN(col)Minimum value

3. ๐Ÿ› ๏ธ SQL Server Functions

SQL Server (T-SQL) includes a rich library of system functions.

๐Ÿ”  String Functions

FunctionDescription
LEN(str)Length of string
REPLACE(str, find, replace)Replace substrings
LEFT(str, n)First n characters
RIGHT(str, n)Last n characters

๐Ÿ•’ Date & Time Functions

FunctionDescription
GETDATE()Current system datetime
DATEADD(day, n, date)Add days to a date
DATEDIFF(day, start, end)Day difference
FORMAT(date, 'dd-MM-yyyy')Format date

โž— Math & Conversion Functions

FunctionDescription
CAST(value AS datatype)Convert data types
CONVERT(datatype, value)Another type conversion
ROUND(num, decimals)Round values
POWER(x, y)x raised to power y

๐Ÿ“Š Ranking & Analytic Functions (SQL Server 2012+)

FunctionDescription
RANK() OVER(...)Ranking within partitions
ROW_NUMBER()Row number in result set
NTILE(n)Divide rows into n buckets

4. ๐Ÿ“‚ MS Access Functions

Microsoft Access supports a variety of VBA-style functions tailored for database manipulation.

๐Ÿ”ค Text Functions

FunctionDescription
Len(text)Length of text
Left(text, n)First n characters
Mid(text, start, length)Extract part of a string
Instr(start, text, find)Find substring position

๐Ÿ“… Date Functions

FunctionDescription
Date()Current system date
Now()Current date and time
DateAdd("d", n, date)Add n days
DateDiff("d", date1, date2)Difference in days

๐Ÿ’ก Miscellaneous

FunctionDescription
Nz(value, substitute)Replace null with substitute
IIf(condition, true, false)Inline conditional
Switch(expr1, result1, expr2, result2...)Multiple condition handler

๐Ÿ“Œ Summary โ€“ Recap & Next Steps

Mastering SQL keywords and built-in functions is key to writing optimized and powerful queries across platforms like MySQL, SQL Server, and MS Access.

๐Ÿ” Key Takeaways:

  • SQL keywords form the backbone of all SQL operations
  • MySQL and SQL Server provide specialized functions for strings, dates, math, and aggregates
  • MS Access offers user-friendly, VBA-like syntax for rapid development

โš™๏ธ Real-World Relevance:
These functions are used daily by database administrators, backend developers, and data analysts to build dynamic applications, generate reports, and maintain data quality.


โ“ FAQ โ€“ SQL References & Functions

โ“ Are SQL keywords case-sensitive?
โœ… No, SQL keywords are case-insensitive, but uppercase improves readability.

โ“ Do MySQL and SQL Server use the same functions?
๐ŸŸก Many are similar, but they have distinct syntax and capabilities. Always check documentation.

โ“ Can I create custom functions in SQL?
โœ… Yes, SQL Server supports user-defined functions (UDFs). MySQL supports them with CREATE FUNCTION.

โ“ What’s the difference between CAST() and CONVERT() in SQL Server?
โœ… Both convert data types. CAST() is ANSI-compliant; CONVERT() allows format styles.


Share Now :
Share

๐Ÿงพ SQL References & Functions

Or Copy Link

CONTENTS
Scroll to Top