A query is a request made to a database to retrieve, insert, update, or delete data. In the context of analytics, queries are most commonly used to retrieve and aggregate data for reporting and analysis.
Types of queries
- SELECT queries — Read data without modifying it. The most common type in analytics.
- Aggregate queries — Use functions like
SUM,COUNT,AVGto summarize data. - Subqueries — Queries nested inside other queries.
- CTEs (Common Table Expressions) — Named temporary result sets that make complex queries more readable.
Natural language queries
With Sequel, you can write queries in plain English. Instead of:
SELECT category, SUM(revenue) as total_revenue
FROM orders
GROUP BY category
ORDER BY total_revenue DESC;
You can simply ask: "What's our revenue by product category?"