SQL exercises

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

SQL VIEW: Exercise-1 with Solution

1. Write a query to create a view for those salesmen belongs 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: Write a query to create a view for all salesmen with columns salesman_id, name and city.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming