8.50. SQLAlchemy Func Numeric
array_agg
- Support for the ARRAY_AGG functioncount
- The ANSI COUNT aggregate function. With no arguments, emitsCOUNT *
cube
- Implement the CUBE grouping operationcume_dist
- Implement the cume_dist hypothetical-set aggregate functiondense_rank
- Implement the dense_rank hypothetical-set aggregate functionmax
- The SQL MAX() aggregate functionmin
- The SQL MIN() aggregate functionmode
- Implement the mode ordered-set aggregate functionpercent_rank
- Implement the percent_rank hypothetical-set aggregate functionpercentile_cont
- Implement the percentile_cont ordered-set aggregate functionpercentile_disc
- Implement the percentile_disc ordered-set aggregate functionrandom
- The RANDOM() SQL functionrank
- Implement the rank hypothetical-set aggregate functionsum
- The SQL SUM() aggregate function
8.50.1. About
Object |
Name Description |
---|---|
|
Support for the ARRAY_AGG function |
|
The ANSI COUNT aggregate function. With no arguments, emits COUNT * |
|
Implement the CUBE grouping operation |
|
Implement the cume_dist hypothetical-set aggregate function |
|
Implement the dense_rank hypothetical-set aggregate function |
|
The SQL MAX() aggregate function |
|
The SQL MIN() aggregate function |
|
Implement the mode ordered-set aggregate function |
|
Implement the percent_rank hypothetical-set aggregate function |
|
Implement the percentile_cont ordered-set aggregate function |
|
Implement the percentile_disc ordered-set aggregate function |
|
The RANDOM() SQL function |
|
Implement the rank hypothetical-set aggregate function |
|
The SQL SUM() aggregate function |
8.50.2. Count
>>> from sqlalchemy import func
>>> from sqlalchemy import distinct
Count User records, without sing a subquery:
>>> session.query(func.count(User.id))
Return count of user 'id' grouped by 'name':
>>> session.query(func.count(User.id)).\
... group_by(User.name)
Count distinct 'name' values:
>>> session.query(func.count(distinct(User.name)))