count
Function
The count function is used to return the number of records.
Syntax
count([distinct|all] <colname>)
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| distinct or all | No | Specifies whether to remove duplicate records when counting. Default is all, which counts all records. If distinct is specified, only unique values are counted. |
| colname | Yes | Column values can be of any type. colname can be *, i.e., count(*), which returns the total number of rows. |
Return Values
Returns a value of type BIGINT.
If colname is NULL, that row is excluded from the calculation.
Examples
- Count the number of records in the warehouse table. Example command:
select count(*) from warehouse;
Result:
_c0 10
- Used with GROUP BY to group all items by warehouse (warehouseId) and count the number of items in each warehouse. Example command:
select warehouseId, count(*) from warehouse group by warehouseId;
Result:
warehouseId _c1 city1 6 city2 5 city3 6
- Use distinct to deduplicate and count the number of warehouses. Example command:
select count(distinct warehouseId) from warehouse;
Result:
_c0 3
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot