1
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 3 years have passed since last update.

【SQL】DISTINCT, 四則演算

Last updated at Posted at 2021-05-27

はじめに

今回は、取得したデータを加工するにはどうすればよいかをみていこうと思います。

DISTINCT

重複するデータを除くことができます。
DISTINCTはSELECTに指定します。
以下のようにすることで、usersテーブルのnumberカラムから重複するデータを除きます。

SELECT DISTINCT(number)
FROM users

ScreenShot 2021-05-27 9.49.24.png

四則演算

以下のようなテーブルのpriceを全て税込にした表を作りたいと思います。

ScreenShot 2021-05-27 9.58.17.png

SELECT number, name, price, price * 1.10
FROM foods;

ScreenShot 2021-05-27 10.02.19.png

他にも足し算は+, 引き算は-, 割り算は/を使います。

おわりに

少しずつ難しくなっていきますが、がんばりましょう!

1
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
1
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?