回答編集履歴
1
update
test
CHANGED
@@ -5,3 +5,13 @@
|
|
5
5
|
SELECT SUM(CASE WHEN (a = 1) THEN 5 ELSE 0 END) AS aa FROM new_table;
|
6
6
|
|
7
7
|
```
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
COALESCEを使うケースも作成してみました。
|
12
|
+
|
13
|
+
```sql
|
14
|
+
|
15
|
+
SELECT SUM(COALESCE(CASE WHEN a = 1 THEN 5 ELSE NULL END, 0)) AS aa FROM new_table;
|
16
|
+
|
17
|
+
```
|