1
我有一個MySQL數據庫是這樣的:分組大量在一起並形成一個上即時AMT列
id - join_id - bool
1 - 32 - 1
2 - 32 - 0
3 - 32 - 1
4 - 32 - 1
我想查詢此:
join_id - bool (- amount)
32 - 1 - 3 (aka there are 3 instances where the join_id and bool are 32 and 1);
32 - 0 - 1 (aka there is 1 instances where the join_id and bool are 32 and 0);
任何關鍵詞,或名字真的很有幫助。
你知道如何用'AS'產生一列設置的默認值? – ThomasReggi
'AS'只是給該列一個別名,這意味着在這種情況下它將出現'amount',而不是被稱爲'COUNT(id)'。每行的默認值完全取決於該列的語句。在這種情況下,我會說'默認'是0 .. – Colin