Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

General Functions in SQL

General Functions in SQL

General Functions in SQL

General functions in SQL are built-in functions that perform common operations on data, such as manipulating strings, numbers, dates, or aggregating values. These functions help you transform, calculate, or retrieve information efficiently within queries.


Common Categories of General Functions:

1. Aggregate Functions

Operate on multiple rows and return a single value.

FunctionDescriptionExample
COUNT()Counts rows or non-null valuesSELECT COUNT(*) FROM users;
SUM()Sum of numeric valuesSELECT SUM(sales) FROM orders;
AVG()Average of numeric valuesSELECT AVG(price) FROM products;
MIN()Minimum valueSELECT MIN(age) FROM employees;
MAX()Maximum valueSELECT MAX(score) FROM tests;

2. String Functions

Manipulate text strings.

FunctionDescriptionExample
CONCAT()Concatenate stringsSELECT CONCAT(first_name, ' ', last_name) FROM users;
LENGTH()Returns length of stringSELECT LENGTH(name) FROM products;
UPPER()Convert to uppercaseSELECT UPPER(city) FROM customers;
LOWER()Convert to lowercaseSELECT LOWER(email) FROM users;
SUBSTRING()Extract substringSELECT SUBSTRING(name, 1, 3) FROM products;
TRIM()Remove spaces from both endsSELECT TRIM(' hello ');

3. Numeric Functions

Perform operations on numbers.

FunctionDescriptionExample
ROUND()Round number to specified decimal placesSELECT ROUND(price, 2) FROM items;
FLOOR()Round down to nearest integerSELECT FLOOR(4.7);
CEIL() or CEILING()Round up to nearest integerSELECT CEIL(4.1);
ABS()Absolute valueSELECT ABS(-10);
POWER()Raise number to powerSELECT POWER(2, 3);
MOD()Modulus (remainder)SELECT MOD(10, 3);

4. Date and Time Functions

Manipulate dates and times.

FunctionDescriptionExample
NOW()Current date and timeSELECT NOW();
CURDATE()Current dateSELECT CURDATE();
DATEADD() / DATE_ADD()Add interval to dateSELECT DATE_ADD(NOW(), INTERVAL 5 DAY);
DATEDIFF()Difference between two datesSELECT DATEDIFF('2025-06-10', '2025-06-01');
YEAR(), MONTH(), DAY()Extract part of a dateSELECT YEAR(NOW());
EXTRACT()Extract part of date/timeSELECT EXTRACT(MONTH FROM NOW());

5. Conditional Functions

FunctionDescriptionExample
COALESCE()Returns first non-NULL valueSELECT COALESCE(NULL, NULL, 5, 10); returns 5
IF()Conditional logic (MySQL)SELECT IF(score > 50, 'Pass', 'Fail');
CASESQL standard conditional expressionsql SELECT CASE WHEN score > 50 THEN 'Pass' ELSE 'Fail' END FROM results;

Summary Table

CategoryExamples
AggregateCOUNT(), SUM(), AVG(), MIN(), MAX()
StringCONCAT(), LENGTH(), UPPER(), LOWER(), SUBSTRING(), TRIM()
NumericROUND(), FLOOR(), CEIL(), ABS(), POWER(), MOD()
Date & TimeNOW(), CURDATE(), DATE_ADD(), DATEDIFF(), YEAR(), EXTRACT()
ConditionalCOALESCE(), IF(), CASE

If you want, I can provide examples or detailed explanations for any specific category or function!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql