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. From the following table, create a view to count the number of customers in each 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: From the following table, create a view to find the salespersons of the city 'New York'.
Next: From the following table, create a view to count the number of unique customer, compute average and total purchase amount of customer orders by each date.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
SQL: Tips of the Day
How to insert a line break in a SQL Server VARCHAR/NVARCHAR string?
DECLARE @text NVARCHAR(100) SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.' SELECT @text
This prints out the following:
This is line 1.
This is line 2.
Database: SQL Server
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework