﻿ SQL VIEW: Create a view that shows all of the customers who have the highest grade - w3resource

# SQL VIEW Exercises: Create a view that shows all of the customers who have the highest grade

## SQL VIEW: Exercise-9 with Solution

9. From the following table, create a view to find all the customers who have the highest grade. Return all the fields of customer.

Sample table: customer

Sample Solution:

``````CREATE VIEW highgrade
AS SELECT *
FROM customer
WHERE grade =
(SELECT MAX (grade)
FROM customer);
``````

output:

```sqlex=# select * from highgrade;
customer_id |   cust_name    |  city  | grade | salesman_id
-------------+----------------+--------+-------+-------------
3008 | Julian Green   | London |   300 |        5002
3004 | Fabian Johnson | Paris  |   300 |        5006
(2 rows)
```

Inventory database model:

Contribute your code and comments through Disqus.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?

﻿

Share this Tutorial / Exercise on : Facebook and Twitter

## 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

Ref: https://bit.ly/3ry1pBI