Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //total
- db.orders.aggregate(
- {
- $group: {
- _id: null,
- total: {
- $sum: '$Freight'
- }
- }
- }
- );
- //France
- db.orders.aggregate(
- {
- $match: {
- ShipCountry: 'France'
- }
- },
- {
- $project: {
- Freight: 1
- }
- },
- {
- $group: {
- _id: null,
- total: {
- $sum: '$Freight',
- },
- totalOrders: {
- $sum: 1
- }
- }
- }
- )
- // total frieght by country
- db.orders.aggregate(
- {
- $project: {
- country: '$ShipCountry',
- amount: '$Freight'
- }
- },
- {
- $group: {
- _id: '$country',
- total: {
- $sum: '$amount'
- },
- totalOrders: {
- $sum: 1
- }
- }
- }
- )
- db.orders.aggregate(
- {
- $group: {
- _id: null,
- total: {
- $sum: '$Freight'
- }
- }
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement