- Section 1: Basics
- 2: User-friendly language
- 3: Documents, not rows
- 4: Pattern matching with LIKE
- 5: Matching elements in nested arrays with ANY
- 6: Combining multiple conditions with AND
- 7: Querying primary keys
- 8: Quick review
- 9: Pagination with LIMIT and OFFSET
- 10: Filtering grouped data with HAVING
- 11. Review
- 12. Section 2: Joins
- 13. Joins
- 14. Joins
- 15. Exercise
- 16. Exercise
- 17. NEST
- 18. Chaining JOINs
- 19. Example
- 20. Array Comprehensions
- 21. Section 3: DML Statements
- 22. Nest
- 23. Nest
- 24. UNNEST
- 25. Filtering on nested data
- 26. Subquery
- 27. Subquery
- 28. Window Functions
- 29. Window Functions
- 30. UPDATE
- 31. Case Study I. E-Commerce
- 32. Shopper - Browsing products from page to page
- 33. Shopper - Listing product categories
- 34. Shopper - Browsing and searching for a product
- 35. Shopper - Listing products in a category
- 36. Shopper - Finding the most popular products in a category
- 37. Shopper - Browsing products and sorting results
- 38. Shopper - Shopping at a one-day sale
- 39. Shopper - Listing the top 10 best selling products
- 40. Shopper - Listing the highest rated products
- 41. Merchant - Preparing a purchase order
- 42. Merchant - Finding the most valued shoppers
- 43. Merchant - Reporting customers by region
- 44. Merchant - Reporting the active monthly customers
- 45. Merchant - Identifying non-performing products
- 46. Merchant - Generating the month-over-month sales report
- 47. Merchant - Big ticket orders
- 48. Case Study II . Social Game
- 49. Assembling and loading user profiles
- 50. Listing messages sent by a user
- 51. Generating scoreboards
The power of the language comes through when we combine several
elements in one query.
The query on the right illustrates many of the previous concepts working together.
1. First we start with all 6 documents FROM the tutorial bucket. It is important to note that the UNNEST step is used to access the nested content of an array by joining it with its parent, as per the N1QL specs. This is used in the query, in order to have access to all the nested entries for children as well. UNNEST is described in Section 2.
2. The WHERE clause eliminates children 10 years old or younger.
3. Next the GROUP BY forms 3 groups, one for each relation ("friend", "parent", "cousin").
4. Then the HAVING clause removes group "parent" (only has 1 member).
5. Next the groups are ordered by the average age of the group members, descending.
6. The we skip over one value in the output and limit the result to a single value.
7. Finally the expressions in the SELECT clause are projected (returned), showing the grouping criteria (relation), the count of items in the group, and average age of the group members.
The query on the right illustrates many of the previous concepts working together.
1. First we start with all 6 documents FROM the tutorial bucket. It is important to note that the UNNEST step is used to access the nested content of an array by joining it with its parent, as per the N1QL specs. This is used in the query, in order to have access to all the nested entries for children as well. UNNEST is described in Section 2.
2. The WHERE clause eliminates children 10 years old or younger.
3. Next the GROUP BY forms 3 groups, one for each relation ("friend", "parent", "cousin").
4. Then the HAVING clause removes group "parent" (only has 1 member).
5. Next the groups are ordered by the average age of the group members, descending.
6. The we skip over one value in the output and limit the result to a single value.
7. Finally the expressions in the SELECT clause are projected (returned), showing the grouping criteria (relation), the count of items in the group, and average age of the group members.
To run this example, click the button in the top right corner of the code editor.