分类: 数据库开发技术
2009-01-26 20:55:16
举例来说,若我们要找出我们的示范表格中有几笔 store_name 栏不是空白的资料时,
Store_Information 表格
|
store_name |
Sales |
Date |
|
Los Angeles |
$1,500 |
Jan-05-1999 |
|
San Diego |
$250 |
Jan-07-1999 |
|
Los Angeles |
$300 |
Jan-08-1999 |
|
Boston |
$700 |
Jan-08-1999 |
我们就打入,
| Count(store_name) |
| 4 |
"is not NULL" 是 "这个栏位不是空白" 的意思。
COUNT 和 DISTINCT 经常被合起来使用,目的是找出表格中有多少笔不同的资料 (至于这些资料实际上是什么并不重要)。 举例来说,如果我们要找出我们的表格中有多少个不同的 store_name,我们就打入,
结果:
| Count(DISTINCT store_name) |
| 3 |
参考: