The document contains SQL statements that create indexes on tables to optimize queries, alters a view to select customer data from the Customers and Sales tables where the sale date is today, creates a view with the same query, and provides example queries to sum total sales by customer, and select customers where the sales amount is greater than 0.
The document contains SQL statements that create indexes on tables to optimize queries, alters a view to select customer data from the Customers and Sales tables where the sale date is today, creates a view with the same query, and provides example queries to sum total sales by customer, and select customers where the sales amount is greater than 0.
The document contains SQL statements that create indexes on tables to optimize queries, alters a view to select customer data from the Customers and Sales tables where the sale date is today, creates a view with the same query, and provides example queries to sum total sales by customer, and select customers where the sales amount is greater than 0.
The document contains SQL statements that create indexes on tables to optimize queries, alters a view to select customer data from the Customers and Sales tables where the sale date is today, creates a view with the same query, and provides example queries to sum total sales by customer, and select customers where the sales amount is greater than 0.
FROM Customers c JOIN Sales s ON c.CustomerID = s.CustomerID WHERE s.Date = CURDATE() ORDER BY c.DateOfBirth;
CREATE INDEX idx_customers ON Customers (CustomerID);
CREATE INDEX idx_sales ON Sales (SalesID); CREATE INDEX idx_products ON Products (ProductID);
CREATE VIEW daily_Customers AS
SELECT c.FirstName, c.LastName, s.Date, s.SalesAmount FROM Customers c JOIN Sales s ON c.CustomerID = s.CustomerID WHERE s.Date = CURDATE() ORDER BY c.DateOfBirth;
SELECT c.FirstName, c.LastName, c.DateOfBirth, SUM(s.SalesAmount) AS TotalSales
FROM Customers c JOIN Sales s ON c.CustomerID = s.CustomerID GROUP BY c.CustomerID ORDER BY TotalSales DESC;