v1.10

Document

How to Start SequoiaDB

Basic Operation

Data Model

Database Management

Aggregation

Index

Replication

Cluster

Connector

Reference

Development

Release Note

FAQ

  • Content
  • Comments
  • History

SQL & Aggregation Mapping

The following table describes the main SQL keywords SequoiaDB aggregation operator table.

SQL keywords SequoiaDB aggregation operator
where $match
group by $group
having $match
select $project
order by $sort
top $limit
offset $skip

The following table describes the standard SQL statements and control statements SequoiaDB gathered between.

SQL statement SequoiaDB gather statement Description
select product_id as p_id, price from table db.cs.table.aggregate({$project:{p_id:"$product_id",price:1,date:0}}) Return product_id and price fields for all records where product_id rename p_id, on the record date field is not returned.
select sum(price) as total from table db.cs.table.aggregate({$group:{_id:null,total:{$sum:"$price"}}}) Price for table summing the values in the field, and rename total.
select product_id, sum(price) as total from table group by product_id db.cs.table.aggregate({$group:{_id:"$product_id",product_id:{$first:"$product_id"},total:{$sum:"$price"}}}) Table of records grouped by product_id field. Find field in each packet accumulation and price value, and rename total.
select product_id, sum(price) as total from table group by product_id order by total db.cs.table.aggregate({$group:{_id:"$product_id",product_id:{$first:"$product_id"},total:{$sum:"$price"}}},{$sort:{total:1}}) Table of records grouped by product_id field. Find the value of the field in each packet price and accumulated, and rename total. The result set by the total value of the field names in ascending order.
select product_type_id, product_id, sum(price) as total from table group by product_type_id, product_id db.cs.table.aggregate({$group:{_id:{product_type_id:"$product_type_id",product_id:"$product_id"},product_id:{$first:"$product_id"},total:{$sum:"$price"}}}) Table records in a field by first grouping by product_type_id press product_id field grouping. Find the value of the field in each packet price and accumulated, and rename total.
select product_id, sum(price) as total from table group by product_id having total > 1000 db.cs.table.aggregate({$group:{_id:"$product_id",product_id:{$first:"$product_id"},total:{$sum:"$price"}}},{$match:{total:{$gt:1000}}}) Table of records grouped by product_id field. Find the value of the field in each packet price and accumulated, and rename total. Total retrun only to meet the conditions grouped field values greater than 1000.
select product_id, sum(price) as total from table where product_type_id = 1001 group by product_id db.cs.table.aggregate({$match:{product_type_id:1001}},{$group:{_id:"$product_id",product_id:{$first:"$product_id"},total:{$sum:"$price"}}}) Select product_type_id = 1001 qualifying record. For the selected records are grouped by product_id. The price for each packet field values on and, and rename total.
select product_id, sum(price) as total from table where product_type_id = 1001 group by product_id having total > 1000 db.cs.table.aggregate({$match:{product_type_id:1001}},{$group:{_id:"$product_id",product_id:{$first:"$product_id"},total:{$sum:"$price"}}},{$match:{total:{$gt:1000}}}) Select product_type_id = 1001 qualifying record. For the selected records are grouped by product_id. The price for each packet field values on and, and rename total. Total return only to meet the conditions grouped field values greater than 1000.
select top 10 * from table db.cs.table.aggregate({$group:{_id:null}},{$limit:10}) Returns the result set before 10 records.
select * from table offset 50 rows fetch next 10 db.cs.table.aggregate({$group:{_id:null}},{$skip:50},{$limit:10}) After skipping the results of 50 focus before recording, return the next 10 records.
please login to comment.
Latest Comment
  • 2015-02-14

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Beijing:
Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Guangzhou:
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Shenzhen:
Tsing Hua Tech Park, Nanshan District, Shenzhen,China
Tel:400-8038-339
E-mail:contact@sequoiadb.com