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

SQLで列から偶数、奇数を出す方法

Last updated at Posted at 2019-11-22

image.png
問題文の要点は2つ:
1、「ID」の列で偶数("even number")の要素を出します。
2、同じ(duplicates)要素を排除(exclude)します。

対策:
1、MODを使います。
2、DISTINCTを使います。

解決コード:
Select distinct city from station where mod(ID,2)=0;
奇数の場合:
Select distinct city from station where mod(ID,2)=1;

1
0
1

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?