Database 03

Database 03

·

2 min read

hello 👋 again.

SQL MIN() and MAX() functions

  • min() returns the smallest value and max() functions is viceversa.

Example

SELECT MIN(price) FROM payroll

SQL COUNT(), AVG() and SUM() function

  • Count() returns the number of rows that matches a specified column. ❗NULL values are not counted
  • AVG() returns the average value of a numeric column. ❗NULL values are ignored.
  • Sum() returns the total of a numeric column.❗NULL values are ignored.

SQL LIKE operator

  • LIKE operator is used in a WHERE condition to search a specified form in a column.
  • wildcards that are often used in conjunction with the LIKE operator:
    • percent sign (%)represents zero, one, or multiple characters
    • underscore sign(_) represents one, a single character

SQL Wildcards

  • This is used to search data within a table.
  • it is often used with the LIKE operator and this operator is used in a WHERE clause to search for a specified pattern in a column.
symbolDescriptionExample
*Represents zero or more charactersfo% fin finds fool, font
-Represents a single characterh_t finds hot, hut, hat and hit
[]any single letter within the bracketsh[oat] find hot and hat but not hit
^any letter not in the bracketh[^oa]t finds hit but not hot and hat
-any single character in the specified rangec[a-b]t finds cat and cbt

SQL IN

  • this operator tests whether a specified value matches any value.
  • IN operator is shorthand for multiple OR conditions.

Example

SELECT * FROM table_name WHERE column IN('value1', 'value2', 'value3');

SQL BETWEEN

  • this operator selects values within a given range and it can be number text or dates

Example

#this will display price 200 to 1000 of the table
SELECT * FROM payroll WHERE price BETWEEN 200 AND 1000

SQL ALIASES

  • This is used to give a table or column a temporary name and often used to make column names more readable.
  • An Aliases only exists for the duraton of that query.

Example

SELECT CustomerNames AS Names FROM Customers

Did you find this article valuable?

Support Yusra by becoming a sponsor. Any amount is appreciated!