0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQL 集計関数+α

Posted at

四則演算

+ 足し算

ー 引き算

* 掛け算

/ 割り算

計算の優先順位

[* , /]> [+ , -]

SELECT カラム名 + - * /

FROM テーブル名;

DISTINCT 重複したデータを省く

DISTINCT 区別すると言う意味

DISTINCTを使用すれば重複したデータをのぞいて検索することができる

SELECT DISTINCT カラム名

FROM テーブル名;

集計関数

  • SUM(カラム名)でそのカラムの合計を求めることができる。

  • AVG(カラム名)でそのカラムの平均を求めることができる。

  • MAX(カラム名)でそのカラムでの最大値を求めることができる。

  • MIN(カラム)でそのカラムでの最小値を求めることができる。

SELECT SUM(カラム名)

FROM テーブル名;

条件指定
SELECT SUM(カラム名)

FROM テーブル名

WHERE カラム名 条件;

集計関数 COUNT

COUNT(カラム名)でデータの数を検索するNULLは含まない

COUNT(*)でNULLを含んだ全てのデータの数を習得する

COUNT(DISTINCT カラム名)で重複したデータを除いたデータ数を求めることができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?