Query examples
40+ natural language database query examples.
Browse real examples of plain-English questions translated into MongoDB aggregation pipelines, Firestore queries, Redis commands, DynamoDB expressions, and Excel aggregations \u2014 all generated by Insight O\u2019 Mate.
MongoDB query examples
Plain English → MongoDB aggregation pipelines, find queries, and countDocuments
Insight O' Mate translates natural language questions into native MongoDB query syntax. These examples demonstrate how plain English prompts are converted into $match, $group, $lookup, and other complex aggregation pipeline stages.
Top 10 customers by total spending this month
db.orders.aggregate([
{ $match: { createdAt: { $gte: startOfMonth } } },
{ $group: { _id: "$customerId", total: { $sum: "$amount" } } },
{ $sort: { total: -1 } },
{ $limit: 10 }
])Count orders placed in the last 7 days
db.orders.countDocuments({
createdAt: { $gte: new Date(Date.now() - 7*24*60*60*1000) }
})Users who signed up but never placed an order
db.users.aggregate([
{ $lookup: { from: "orders", localField: "_id",
foreignField: "userId", as: "orders" } },
{ $match: { orders: { $size: 0 } } }
])Orders grouped by status with count
db.orders.aggregate([
{ $group: { _id: "$status", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
])Top 5 products by revenue
db.orders.aggregate([
{ $unwind: "$items" },
{ $group: { _id: "$items.productId",
revenue: { $sum: { $multiply: ["$items.price", "$items.quantity"] } } } },
{ $sort: { revenue: -1 } },
{ $limit: 5 }
])Users created in last 30 days with unverified emails
db.users.find({
createdAt: { $gte: new Date(Date.now() - 30*24*60*60*1000) },
emailVerified: false
})Distinct values in the 'category' field
db.products.distinct("category")Users with more than 3 orders this month
db.orders.aggregate([
{ $match: { createdAt: { $gte: startOfMonth } } },
{ $group: { _id: "$userId", count: { $sum: 1 } } },
{ $match: { count: { $gt: 3 } } }
])Firebase Firestore query examples
Plain English → Firestore collection queries with where filters, orderBy, and count()
These examples show how Insight O' Mate generates Firestore Admin SDK queries, automatically handling compound where clauses, orderBy constraints, and pagination limits from conversational input.
Active users who joined in the last 30 days
db.collection("users")
.where("status", "==", "active")
.where("createdAt", ">=", thirtyDaysAgo)
.orderBy("createdAt", "desc")
.get()Count pending orders
db.collection("orders")
.where("status", "==", "pending")
.count().get()Blog posts tagged 'AI' ordered by publish date
db.collection("posts")
.where("tags", "array-contains", "AI")
.orderBy("publishedAt", "desc")
.limit(20).get()Users from India
db.collection("users")
.where("country", "==", "India")
.get()Products with inventory below 10
db.collection("products")
.where("stock", "<", 10)
.orderBy("stock", "asc")
.get()5 most recent open support tickets
db.collection("tickets")
.where("status", "==", "open")
.orderBy("createdAt", "desc")
.limit(5).get()Orders created today
db.collection("orders")
.where("createdAt", ">=", startOfDay)
.orderBy("createdAt", "desc")
.get()Redis query examples
Plain English → Redis commands for Hashes, Sorted Sets, Lists, Sets, and Streams
Insight O' Mate acts as an AI Redis copilot. It infers the correct data structure command (e.g., ZRANGEBYSCORE, HGETALL) and safely utilizes SCAN for key pattern matching to prevent event loop blocking.
Users with score above 1000 in the leaderboard
ZRANGEBYSCORE leaderboard 1000 +inf WITHSCORESProfile for user:42
HGETALL user:42How many keys match session:* pattern
SCAN 0 MATCH session:* COUNT 100
# Iterate until cursor returns 05 most recent messages in chat:room1 stream
XREVRANGE chat:room1 + - COUNT 5All members of the 'admins' set
SMEMBERS adminsLast 20 items from the notifications list
LRANGE notifications -20 -1TTL for session:abc123
TTL session:abc123Top 3 leaderboard entries with scores
ZREVRANGE leaderboard 0 2 WITHSCORESAmazon DynamoDB query examples
Plain English → DynamoDB Query/Scan with automatic expression and reserved-word handling
Generating DynamoDB JSON syntax can be tedious. These examples illustrate how the AI automatically handles ExpressionAttributeNames and ExpressionAttributeValues for complex filter expressions.
All orders for customer 'user-123' in the last 30 days
{
TableName: "orders",
KeyConditionExpression:
"customerId = :cid AND createdAt >= :date",
ExpressionAttributeValues: {
":cid": { S: "user-123" },
":date": { S: thirtyDaysAgo.toISOString() }
}
}Electronics products under $100
{
TableName: "products",
FilterExpression:
"#cat = :category AND #price < :max",
ExpressionAttributeNames: {
"#cat": "category", "#price": "price"
},
ExpressionAttributeValues: {
":category": { S: "Electronics" },
":max": { N: "100" }
}
}Count of active subscriptions
{
TableName: "subscriptions",
FilterExpression: "#status = :active",
ExpressionAttributeNames: { "#status": "status" },
ExpressionAttributeValues: { ":active": { S: "active" } },
Select: "COUNT"
}Most recent order for customer 'user-456'
{
TableName: "orders",
KeyConditionExpression: "customerId = :cid",
ExpressionAttributeValues: { ":cid": { S: "user-456" } },
ScanIndexForward: false,
Limit: 1
}Users whose name starts with 'Alex'
{
TableName: "users",
FilterExpression: "begins_with(#name, :prefix)",
ExpressionAttributeNames: { "#name": "name" },
ExpressionAttributeValues: { ":prefix": { S: "Alex" } }
}Payments between $100 and $500
{
TableName: "payments",
FilterExpression: "#amount BETWEEN :min AND :max",
ExpressionAttributeNames: { "#amount": "amount" },
ExpressionAttributeValues: {
":min": { N: "100" }, ":max": { N: "500" }
}
}Excel & CSV query examples
Plain English → In-memory aggregations, filters, and cross-sheet joins
Without relying on VLOOKUP or pivot tables, Insight O' Mate parses spreadsheets locally and performs SQL-like aggregations, filtering, and cross-sheet joins entirely in memory based on English prompts.
Total revenue by product category
GROUP BY category
SUM(revenue) AS total_revenue
ORDER BY total_revenue DESCCustomers who spent more than $500 this month
FILTER WHERE
order_date >= first_day_of_month
AND total_amount > 500Join Orders sheet with Customers sheet by CustomerID
JOIN Orders ON
Orders.CustomerID = Customers.CustomerIDAverage order value by month in 2024
GROUP BY MONTH(order_date)
WHERE YEAR(order_date) = 2024
AVG(order_total) AS avg_order_value
ORDER BY month ASCCount rows where status is 'Approved'
COUNT(*) WHERE status = 'Approved'Duplicate email addresses in contacts
GROUP BY email
HAVING COUNT(*) > 1
SELECT email, COUNT(*) AS occurrencesTop 10 products by quantity sold
GROUP BY product_name
SUM(quantity) AS total_quantity
ORDER BY total_quantity DESC
LIMIT 10Total expenses per department
GROUP BY department
SUM(amount) AS total_expenses
ORDER BY total_expenses DESCTry these queries with your own data
Connect your own MongoDB, Firestore, Redis, DynamoDB, or spreadsheet and start asking questions in plain English.