SQL VIEW Exercises: Define a view that shows the number of orders in each day
SQL VIEW: Exercise-14 with Solution
14. Write a query to create a view that shows the number of orders in each day.
Sample table: orders
CREATE VIEW dateord(ord_date, odcount) AS SELECT ord_date, COUNT (*) FROM orders GROUP BY ord_date;
sqlpractice=# SELECT * sqlpractice-# FROM dateord; ord_date | odcount ------------+--------- 2012-10-05 | 2 2012-08-17 | 3 2012-07-27 | 1 2012-09-22 | 1 2012-09-10 | 3 2012-10-10 | 2 2012-06-27 | 1 2012-04-25 | 1 (8 rows)
Inventory database model:
Contribute your code and comments through Disqus.
Previous: Write a query to create a view that shows all matches of customers with salesman such that at least one customer in the city of customer served by a salesman in the city of the salesman.
Next: Write a query to create a view that finds the salesmen who issued orders on October 10th, 2012.
What is the difficulty level of this exercise?