Aim: To perform simple queries,string manipulation operations and
aggregate functions.
Software Required: MY SQL
Theory: SQL aggregation function is used to perform the
calculations on multiple rows of a single column of a table. It
returns a single [Link] is also used to summarize the data.
These are just a few examples, and there are many other SQL
functions and features available for working with data in a database.
Simple Queries:
Select all rows from a table:
SQL
SELECT * FROM table_name;
Select specific columns from a table:
SQL
SELECT column1, column2 FROM table_name;
Select rows based on a condition:
SQL
SELECT * FROM table_name WHERE condition;
String Manipulation Operations:
Convert a string to uppercase:
SQL
SELECT UPPER(column_name) FROM table_name;
Extract a substring from a string:
SQL
SELECT SUBSTRING(column_name, start_position, length) FROM table_name;
Concatenate strings:
SQL
SELECT CONCAT(column1, ' ', column2) FROM table_name;
Aggregate Functions:
Count the number of rows in a table:
SQL
SELECT COUNT(*) FROM table_name;
Calculate the average of a column:
SQL
SELECT AVG(column_name) FROM table_name;
Find the minimum value in a column:
SQL
SELECT MIN(column_name) FROM table_name;
Find the maximum value in a column:
SQL
SELECT MAX(column_name) FROM table_name;
Conclusion: We have successfully performed string manipulation
operations and aggregate functions in SQL.