アプリ関連ニュース
- 2020年7月15日
- Android
Android 11に触れてみました
tanaka at 2020年07月15日 10:00:20
GeforceNow正式サービス開始
tanaka at 2020年07月08日 10:00:09
- 2020年7月03日
- 技術情報
[Laravel]バッチ処理のタスクスケジュール
nishida at 2020年07月03日 10:00:00
- 2020年6月19日
- 技術情報
[SQL]年齢による条件抽出
データベースレコードには「生年月日」のカラムがありますが、「年齢」のカラムはありません。そのような場合に年齢によるSQLの条件抽出をおこなうためにはどのようにSQLを組み立てていけばいいのでしょうか。
続きを読むnishida at 2020年06月19日 10:00:45
- 2020年6月15日
- 技術情報
Common Aggregate Functions in SQL
Today I will talk about some common aggregate functions that are widely used in SQL programming language.
Count
if we want to get the count of all records or specific where condition records, we can get by using count function.
SELECT COUNT(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name WHERE condition;
AVG
For average rate calculations, we can use this.
SELECT AVG(column_name) FROM table_name;
SELECT AVG(column_name) FROM table_name WHERE condition;
SUM
For sum results of all records, we can use this.
SELECT SUM(column_name) FROM table_name
SELECT SUM(column_name) FROM table_name WHERE condition;
MIN
For specific minimum result of a column, we can use this.
SELECT MIN(column_name) FROM table_name;
SELECT MIN(column_name) FROM table_name WHERE condition;
Likewise min, we can use max to get maximum result.
SELECT MAX(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name WHERE condition;
By Yuuma
yuuma at 2020年06月15日 11:00:24