content_image/673659.jpg
## 7.4.3 SQL to Aggregation Mapping Chart 

The aggregation pipeline (page 439) allows MongoDB to provide native aggregation capabilities that corresponds to many common data aggregation operations in SQL. 

The following table provides an overview of common SQL aggregation terms, functions, and concepts and the corre- sponding MongoDB aggregation operators : 

<img src='content_image/673659.jpg'>

## Examples 

The following table presents a quick reference of SQL aggregation statements and the corresponding MongoDB state- ments. The examples in the table assume the following conditions: 

• The SQL examples assume two tables, orders and order_lineitem that join by the order_lineitem.order_id and the orders.id columns. 

• The MongoDB examples assume one collection orders that contain documents of the following prototype: 

{ cust_id: "abc123", ord_date: ISODate("2012-11-02T17:04:11.102Z"), status: 'A', price: 50, items: [ { sku: "xxx", qty: 25, price: 1 }, { sku: "yyy", qty: 25, price: 1 } ] } 

