Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Introduction to Numeric Functions | Section
Essential SQL Functions for Data Cleaning and Transformation

bookIntroduction to Numeric Functions

メニューを表示するにはスワイプしてください

Numeric functions in SQL are essential tools for analyzing and transforming numerical data stored in your tables. You use these functions to round values, perform mathematical calculations, and extract specific numeric information from your data. Whether you are calculating totals, adjusting prices, or preparing data for reports, numeric functions help you get accurate and meaningful results from your queries.

1234567891011
-- Use ROUND to round prices to the nearest whole number SELECT name, price, ROUND(price) AS rounded_price FROM products; -- Use CEILING to always round prices up SELECT name, price, CEILING(price) AS ceiling_price FROM products; -- Use FLOOR to always round prices down SELECT name, price, FLOOR(price) AS floor_price FROM products;
copy

You can also use numeric functions like ABS and POWER for more advanced calculations. The ABS function returns the absolute value of a number, which is useful when you need to remove any negative sign from a result. The POWER function raises a number to a specified power, allowing you to calculate exponents or squares of values as needed for your analysis.

1234567
-- Use MOD to find the remainder of stock divided by 10 SELECT name, stock, MOD(stock, 10) AS stock_remainder FROM products; -- Use SQRT to calculate the square root of the price SELECT name, price, SQRT(price) AS price_sqrt FROM products;
copy

1. Which function rounds a number up to the nearest integer?

2. What does the MOD function return?

3. Fill in the blanks to calculate the square root of the price for each product.

question mark

Which function rounds a number up to the nearest integer?

正しい答えを選んでください

question mark

What does the MOD function return?

正しい答えを選んでください

question-icon

Fill in the blanks to calculate the square root of the price for each product.

SELECT name, price, (price) AS price_sqrt FROM products;
Wireless Mouse|25.99|5.098039
Mechanical Keyboard|79.99|8.944272
USB-C Charger|19.50|4.415880
27-inch Monitor|229.99|15.165750
Bluetooth Headphones|59.99|7.745967
Webcam HD|39.99|6.324555
External Hard Drive 1TB|69.99|8.366600
Gaming Chair|149.99|12.247449
Laptop Stand|34.99|5.915475
Smartphone Holder|12.99|3.603883

クリックまたはドラッグ`n`ドロップして空欄を埋めてください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  13

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  13
some-alt