4 Apr 2024 Martyna Sławińska SQL Numeric Functions Review all the SQL numeric functions, including their definitions and examples. SQL’s numeric functions perform operations on numbers. They take one or more numbers as arguments and return a number as output. Note that numbers may be of different data types, including integers, doubles, and floats. You can learn more about numeric and decimal data types here. SQL numeric functions can be divided into scalar and aggregate functions. Scalar functions compute a result for each input row individually. Read more 25 Aug 2021 LearnSQL.com Team Standard SQL Functions Cheat Sheet Welcome to the ultimate resource for mastering SQL functions - the Standard SQL Functions Cheat Sheet. It's designed to be a quick yet comprehensive reference guide for both beginners and experts. Download yours and start querying with ease. Whether you are a beginner stepping into the world of SQL or a seasoned professional looking to brush up on your skills, our Standard SQL Functions Cheat Sheet is designed to be your go-to guide for SQL functions. Read more Latest Articles 16 Apr 2024 Agnieszka Kozubek-Krycuń SQL MAX Function Learn about the SQL MAX function, which is used to find the highest value in your dataset. This article explains how to use the syntax of MAX function and shows typical usage examples. The SQL MAX function is an aggregate function that returns the maximum value in a column. MAX function, together with its counterpart MIN function, is useful for summarizing data in data analysis. It can help you to compute the range of values in a dataset. Read more 29 Jun 2023 Radu Gheorghiu How to Use COUNT() with GROUP BY: 5 Practical Examples Using the COUNT() function with GROUP BY is one of the most common SQL constructs in aggregate queries. Read this article to find out how to use COUNT() with GROUP BY correctly using 5 examples. In this article, we will explain the importance of using COUNT with GROUP BY. We’ll talk about why it is essential in SQL and how it enables data analysis and summarization based on specific criteria. Read more 31 Mar 2022 Ignacio L. Bisso How to Use the ROUND() Function in SQL Need to round numeric results in SQL? The ROUND() function is here to do the job. Modern relational databases offer many built-in functions that extend the capabilities of SQL. In this article, we will use practical examples to explain how the ROUND() function works. (Spoiler alert: If you guessed that it rounds a number to a certain decimal place, you’re right! Read on to find out more.) SQL Standard Functions Each SQL database (PostgreSQL, MySQL, Oracle, SQL Server among others) has a set of built-in functions. Read more 31 Aug 2021 Dorota Wdzięczna SQL MIN and MAX Functions Explained in 6 Examples What are the SQL MIN() and MAX() functions? When should you use them as aggregate functions, and when should you use them with window functions? We explain using practical examples. SQL includes several aggregate functions. These aggregate functions compute calculations on numerical data. This article focuses on only two of these functions: MIN() and MAX(). I will explain what each function does and discuss several use cases. If you want to practice SQL aggregate functions, I recommend our interactive SQL Practice Set course. Read more 23 Jul 2021 Dorota Wdzięczna SQL SUM() Function Explained with 5 Practical Examples Aggregate functions are an important part of SQL knowledge – and there’s no better place to start learning them than with the SUM() function. In this article, you can expand or refresh your SQL with 5 practical examples of SUM(). SQL allows us to do more than select values or expressions from tables. Most operations on relational databases use aggregate functions like SUM() to do computations on data. Read more 4 Jun 2021 Andrew Bone How the Division Operator Works in SQL The division operator in SQL is used to divide one expression or number by another. This article will show you exactly how to use it and common mistakes to avoid along the way. The best way to practice SQL is our interactive SQL Practice track. It contains over 600 hands-on exercises that conver varios SQL topics, from simple one-table queries, through JOINs, to complex topics like subqueries. It lets you train your SQL skills on real business examples. Read more 30 Dec 2020 How to Calculate a Square Root in SQL Problem You want to find the square root of a number in SQ:. Example You want to compute the square root of all numbers in the column number from the table data. number 9 2 1 0.25 0 -4 Solution SELECT number, SQRT(number) AS square_root FROM data; The result is: Read more 6 Nov 2020 How to Compute an Absolute Value in SQL Problem You want to find the absolute value of a number in SQL. Example You want to compute the absolute value of each number in the column numbers from the table data. numbers -3.2 0 20 Solution SELECT ABS(numbers) AS absolute_values FROM data; The result is: absolute_values 3. Read more 6 Nov 2020 How to Calculate a Square in SQL Problem You want to find the square of a number in SQL. Example You want to compute the square of each number in the column number from the table data. number 3 1 0.5 0 -2 Solution 1: Use SQUARE function SELECT number, SQUARE(number) AS square FROM data; Solution 2: Use multiplication operator * SELECT number, number * number AS square FROM data; Solution 3: Use POWER function SELECT number, POWER(number, 2) AS square FROM data; The result is: Read more 27 Nov 2019 How to Round Up a Number to the Nearest Integer in SQL Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent. Read more 27 Nov 2019 How to Round Numbers in SQL Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places. Read more 27 Nov 2019 How to Floor Numbers in SQL Problem You want to round a number down to the nearest integer. Example Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked. Read more 25 Nov 2019 How to Handle Divide by Zero In SQL Problem You want to perform division in your SQL query, but the denominator is an expression that can be zero. The database will give you an error when the denominator is in fact zero. Example Our database has a table named investor_data with data in the following columns: id, investor_year, price_per_share, income, and expenses. idinvestor_yearprice_per_shareincomeexpenses 120162032002300 2201713020002000 3201840200100 420191559004900 Let’s divide the price per share by the difference between income and expenses to determine the P/E ratio (price-earnings ratio) for each year. Read more 5 Jan 2018 Aldo Zelen 18 Useful Important SQL Functions to Learn ASAP Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike. Read more 18 Apr 2017 Aldo Zelen Understanding Numerical Data Types in SQL Working with databases of any kind means working with data. This data can take a couple of predefined formats. As you start on your learning path with LearnSQL.com, you will start to understand SQL's different data types. In this article, we will cover different variations of the SQL numeric data type. We'll also examine some functions that convert data from one type to another. Creating tables is the first step in any SQL coding project. Read more