teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2019/07/10 03:44

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -10,4 +10,15 @@
10
10
  ) uit2
11
11
  ON uit.RegistrationCode = uit2.RegistrationCode
12
12
  GROUP BY uit.RegistrationCode
13
+ ```
14
+ 追記
15
+ --
16
+ インラインビューを使用せずに、以下の様な結合でも大丈夫じゃないかな。
17
+ ※COUNT()はNUllをカウントしない
18
+ ```SQL
19
+ SELECT uit.RegistrationCode, count(uit2.RegistrationCode) count
20
+ FROM user_info_table uit LEFT JOIN user_info_table uit2
21
+ on uit.RegistrationCode = uit2.RegistrationCode
22
+ and uit2.EndFlg = 0 AND uit2.PaymentFlg = 1
23
+ GROUP BY uit.RegistrationCode
13
24
  ```