

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 比較演算子
<a name="comparison-operators"></a>

比較条件では、2 つの値の間の論理的な関係を指定します。比較条件はすべて、ブール型の戻り値を返す 2 項演算子です。

AWS Clean Rooms Spark SQL は、次の表で説明する比較演算子をサポートしています。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/clean-rooms/latest/sql-reference/comparison-operators.html)

## 例
<a name="comparison-condition-example"></a>

ここで、比較条件の簡単な例をいくつか示します。

```
a = 5
a < b
min(x) >= 5
qtysold = any (select qtysold from sales where dateid = 1882
```

次のクエリは、現在フォージングされていないすべてのリスの ID 値を返します。

```
SELECT id FROM squirrels 
WHERE !is_foraging
```

次のクエリは、VENUE テーブルから席数が 10,000 席を超える会場を返します。

```
select venueid, venuename, venueseats from venue
where venueseats > 10000
order by venueseats desc;

venueid |           venuename            | venueseats
---------+--------------------------------+------------
83 | FedExField                     |      91704
 6 | New York Giants Stadium        |      80242
79 | Arrowhead Stadium              |      79451
78 | INVESCO Field                  |      76125
69 | Dolphin Stadium                |      74916
67 | Ralph Wilson Stadium           |      73967
76 | Jacksonville Municipal Stadium |      73800
89 | Bank of America Stadium        |      73298
72 | Cleveland Browns Stadium       |      73200
86 | Lambeau Field                  |      72922
...
(57 rows)
```

この例では、USERS テーブルからロックミュージックが好きなユーザー (USERID) を選択します。

```
select userid from users where likerock = 't' order by 1 limit 5;

userid
--------
3
5
6
13
16
(5 rows)
```

この例では、USERS テーブルから、ロックミュージックを好きかどうか不明であるユーザー (USERID) を選択します。

```
select firstname, lastname, likerock
from users
where likerock is unknown
order by userid limit 10;

firstname | lastname | likerock
----------+----------+----------
Rafael    | Taylor   |
Vladimir  | Humphrey |
Barry     | Roy      |
Tamekah   | Juarez   |
Mufutau   | Watkins  |
Naida     | Calderon |
Anika     | Huff     |
Bruce     | Beck     |
Mallory   | Farrell  |
Scarlett  | Mayer    |
(10 rows
```

## TIME 列の例
<a name="comparison-condition-example-time"></a>

次のテーブルの TIME\$1TEST の例には、3 つの値が挿入された列 TIME\$1VAL (タイプ TIME) があります。

```
select time_val from time_test;
            
time_val
---------------------
20:00:00
00:00:00.5550
00:58:00
```

次の例では、各 timetz\$1val から時間を抽出します。

```
select time_val from time_test where time_val < '3:00';
   time_val
---------------
 00:00:00.5550
 00:58:00
```

次の例では、2 つの時刻リテラルを比較します。

```
select time '18:25:33.123456' = time '18:25:33.123456';
 ?column?
----------
 t
```

## TIMETZ 列の例
<a name="comparison-condition-example-timetz"></a>

次のテーブルの TIMETZ\$1TEST の例には、3 つの値が挿入された列 TIMETZ\$1VAL (タイプ TIMETZ) があります。

```
select timetz_val from timetz_test;
            
timetz_val
------------------
04:00:00+00
00:00:00.5550+00
05:58:00+00
```

次の例では、`3:00:00 UTC` 未満の TIMETZ 値のみを選択します。値を UTC に変換した後に比較が行われます。

```
select timetz_val from timetz_test where timetz_val < '3:00:00 UTC';
                  
   timetz_val
---------------
 00:00:00.5550+00
```

次の例では、2 つの TIMETZ リテラルを比較します。タイムゾーンは、比較のために無視されます。

```
select time '18:25:33.123456 PST' < time '19:25:33.123456 EST';
                  
 ?column?
----------
 t
```