SQL VIEW Exercises: Create a view to get a count of how many customers we have at each level of grade
SQL VIEW: Exercise-4 with Solution
4. Write a query to create a view to getting a count of how many customers we have at each level of a grade.
Sample table: customer
CREATE VIEW gradecount (grade, number) AS SELECT grade, COUNT(*) FROM customer GROUP BY grade;
sqlpractice=# SELECT * sqlpractice-# FROM gradecount sqlpractice-# WHERE number = 2; grade | number -------+-------- | 2 200 | 2 300 | 2 (3 rows)
Inventory database model:
Contribute your code and comments through Disqus.
Previous: Write a query to find the salesmen of the city New York who achieved the commission more than 13%.
Next: Write a query to create a view to keeping track the number of customers ordering number of salesmen attached, average amount of orders and the total amount of orders in a day.
What is the difficulty level of this exercise?