SQL VIEW Exercises: Create a view for the salesmen who belongs to the city New York

SQL VIEW: Exercise-1 with Solution

1. From the following table, create a view for those salespersons belong to the city 'New York'.

Sample table: salesman

Sample Solution:

CREATE VIEW newyorkstaff
FROM salesman
WHERE city = 'New York';

Sample Output:

sqlpractice=# select * from newyorkstaff;
 salesman_id |    name    |   city   | commission
        5001 | James Hoog | New York |       0.15
(1 row)

Inventory database model:

Inventory database model

Contribute your code and comments through Disqus.

Previous: SQL VIEW Exercises Home
Next: From the following table, create a view for all salespersons. Return salesperson ID, name, and city.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?

SQL: Tips of the Day

MySQL export schema without data

mysqldump -h yourhostnameorIP -u root -p --no-data dbname > schema.sql

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