w3resource
SQL exercises

SQL VIEW Exercises: Create a view that shows the salesmen who issued orders on either August 17th, 2012 or October 10th, 2012

SQL VIEW : Exercise-16 with Solution

16. Write a query to create a view that find the salesmen who issued orders on either August 17th, 2012 or October 10th, 2012.

Sample table: orders


Sample Solution:

CREATE VIEW sorder
AS SELECT salesman_id, ord_no, customer_id
FROM orders
WHERE ord_date IN('2012-08-17', '2012-10-10');

output:

sqlpractice=# SELECT *
sqlpractice-# FROM sorder;
 salesman_id | ord_no | customer_id
-------------+--------+-------------
        5003 |  70004 |        3009
        5006 |  70010 |        3004
        5003 |  70003 |        3009
        5007 |  70011 |        3003
        5007 |  70014 |        3005
(5 rows)

Inventory database model:

Inventory database model

Contribute your code and comments through Disqus.

Previous: Write a query to create a view that finds the salesmen who issued orders on October 10th, 2012.
Next: SQL User Management Exercises Home

What is the difficulty level of this exercise?



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