Sample View Examples
This section demonstrates how to query views in Suadeo. Views are read-only data sources that may represent single tables, aggregated data, or joined information. The specific views and structures available depend on your Suadeo environment configuration.
View Structure Example
Assume you have a custom view named CustomerOrders that combines customer and order information:
- CustomerId (Integer) - Customer identifier
- CustomerName (String) - Customer name
- OrderId (Integer) - Order identifier
- OrderDate (DateTime) - When the order was placed
- OrderTotal (Decimal) - Total order amount
- OrderStatus (String) - Current order status
Select
The driver uses SQL passthrough - your queries are sent directly to Suadeo for server-side execution. Only SELECT operations are supported.
-- Select all records
SELECT * FROM CustomerOrders
-- Filter by conditions
SELECT * FROM CustomerOrders
WHERE CustomerName = 'Acme Corp' AND OrderStatus = 'Completed'
-- Filter by date range
SELECT * FROM CustomerOrders
WHERE OrderDate >= '2024-01-01' AND OrderTotal > 1000
-- Use IN operator
SELECT * FROM CustomerOrders
WHERE OrderStatus IN ('Pending', 'Processing', 'Shipped')
Aggregation
Aggregation functions are processed server-side by Suadeo:
-- Count and sum by group
SELECT CustomerName, COUNT(*) as OrderCount, SUM(OrderTotal) as TotalSales
FROM CustomerOrders
GROUP BY CustomerName
-- Multiple aggregations with filtering
SELECT OrderStatus,
COUNT(*) as OrderCount,
AVG(OrderTotal) as AvgOrderValue
FROM CustomerOrders
GROUP BY OrderStatus
HAVING COUNT(*) > 10
Joining Views
Views can be joined with other views:
-- Inner join SELECT co.CustomerName, co.OrderTotal, od.ProductName FROM CustomerOrders co INNER JOIN OrderDetails od ON co.OrderId = od.OrderId -- Left join SELECT co.CustomerName, co.OrderTotal, p.PaymentMethod FROM CustomerOrders co LEFT JOIN PaymentDetails p ON co.OrderId = p.OrderId
Sorting and Limiting
-- Sort results SELECT * FROM CustomerOrders ORDER BY OrderDate DESC, OrderTotal DESC -- Limit results SELECT TOP 10 CustomerName, OrderTotal FROM CustomerOrders ORDER BY OrderTotal DESC
Important Notes
- Views are read-only. INSERT, UPDATE, and DELETE operations are not supported.
- All SQL queries are executed server-side by Suadeo using SQL passthrough.
- SQL features and syntax depend on Suadeo's SQL engine capabilities.
- Use the CreateSchema stored procedure to generate schema definition files for specific views.
- The PageSize connection property controls how many rows are fetched per request during pagination.