- 전체
- Sample DB
- database modeling
- [표준 SQL] Standard SQL
- G-SQL
- 10-Min
- ORACLE
- MS SQLserver
- MySQL
- SQLite
- postgreSQL
- 데이터아키텍처전문가 - 국가공인자격
- 데이터 분석 전문가 [ADP]
- [국가공인] SQL 개발자/전문가
- NoSQL
- hadoop
- hadoop eco system
- big data (빅데이터)
- stat(통계) R 언어
- XML DB & XQuery
- spark
- DataBase Tool
- 데이터분석 & 데이터사이언스
- Engineer Quality Management
- [기계학습] machine learning
- 데이터 수집 및 전처리
- 국가기술자격 빅데이터분석기사
- 암호화폐 (비트코인, cryptocurrency, bitcoin)
NoSQL [mongodb] SQL to Aggregation Mapping Chart 몽고디비 SQL 쿼리 매핑
2020.09.23 17:33
[mongodb] SQL to Aggregation Mapping Chart 몽고디비 SQL 쿼리 매핑
SQL to Aggregation Mapping Chart
On this page
The aggregation pipeline 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 corresponding MongoDB aggregation operators:
SQL Terms, Functions, and Concepts | MongoDB Aggregation Operators |
---|---|
WHERE | $match |
GROUP BY | $group |
HAVING | $match |
SELECT | $project |
ORDER BY | $sort |
LIMIT | $limit |
SUM() | $sum |
COUNT() | |
join | $lookup |
SELECT INTO NEW_TABLE | $out |
MERGE INTO TABLE | $merge (Available starting in MongoDB 4.2) |
UNION ALL | $unionWith (Available starting in MongoDB 4.4) |
For a list of all aggregation pipeline and expression operators, see Aggregation Pipeline Quick Reference.
SEE ALSO
Examples
The following table presents a quick reference of SQL aggregation statements and the corresponding MongoDB statements. The examples in the table assume the following conditions:
-
The SQL examples assume two tables,
orders
andorder_lineitem
that join by theorder_lineitem.order_id
and theorders.id
columns. -
The MongoDB examples assume one collection
orders
that contain documents of the following prototype:
SQL Example | MongoDB Example | Description |
---|---|---|
Count all records from orders |
||
Sum the price field from orders |
||
For each unique cust_id , sum the price field. |
||
For each unique cust_id , sum the price field, results sorted by sum. |
||
For each unique cust_id , ord_date grouping, sum the price field. Excludes the time portion of the date. |
||
For cust_id with multiple records, return the cust_id and the corresponding record count. |
||
For each unique cust_id , ord_date grouping, sum the price field and return only where the sum is greater than 250. Excludes the time portion of the date. |
||
For each unique cust_id with status A , sum the price field. |
||
For each unique cust_id with status A , sum the price field and return only where the sum is greater than 250. |
||
For each unique cust_id , sum the corresponding line item qty fields associated with the orders. |
||
Count the number of distinct cust_id , ord_date groupings. Excludes the time portion of the date. |
[출처] https://docs.mongodb.com/manual/reference/sql-aggregation-comparison/
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.