returns the number of values (NULL values will not be counted) of the specified column
SELECT COUNT(column_name) FROM table_name
The COUNT(*) function returns the number of records in a table:
SELECT COUNT(*) FROM table_name
| O_Id | OrderDate | Price | 顧客 |
| 1 | 20011/11/12 | 100 | ans |
| 2 | 20011/11/12 | 100 | dce |
| 3 | 20011/11/14 | 100 | abc |
| 4 | 20011/11/15 | 100 | ans |
尋找顧客ans購買次數:
SELECT COUNT(顧客) AS CustomerNilsen FROM Orders
WHERE 顧客='ans'
沒有留言:
張貼留言