Last active
June 10, 2020 01:39
-
-
Save mis101247/c76726804ae061ff6eddd7c72217f175 to your computer and use it in GitHub Desktop.
SQL 實用筆記
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 當你要算出一張表的總數和表內的特定總數 | |
# 範例: 找出姓柯的總人數和其中使用iphone的人數 | |
# 醬子就只會刷一次表 | |
SELECT COUNT(*) as total, COUNT(IF (phone = 'iphone' , 1 ,null)) as iphoneTotal FROM | |
(SELECT * FROM `users` where `last_name` = '柯') AS usersTable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment