w3resource
SQL exercises

SQL VIEW Exercises: Find the salesmen of the city New York who achieved the commission more than 13 percent

SQL VIEW : Exercise-3 with Solution

3. Write a query to find the salesmen of the city New York who achieved the commission more than 13%.

Sample table: salesman


Sample Solution:

Code to create the view

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

Code to see the records form the view

SELECT *
FROM newyorkstaff
WHERE commission > .13;

output

sqlpractice=# SELECT *
sqlpractice-# FROM newyorkstaff
sqlpractice-# WHERE commission > .13;
 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: Write a query to create a view for all salesmen with columns salesman_id, name and city.
Next: Write a query to create a view to getting a count of how many customers we have at each level of a grade.

What is the difficulty level of this exercise?



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