w3resource

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. From the following table, create a view to find the salespersons who issued orders on either August 17th, 2012 or October 10th, 2012. Return salesperson ID, order number and customer ID.

Sample table: orders


Sample Solution:

CREATE VIEW sorder
AS SELECT salesman_id, ord_no, customer_id
FROM orders
WHERE ord_dateIN('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: From the following tables, create a view to find the salespersons who issued orders on October 10th, 2012. Return all the fields of salesperson.
Next: SQL User Management Exercises Home

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 restore a dump file from mysqldump?

It should be as simple as running this:

mysql -u <user> -p < db_backup.dump

If the dump is of a single database you may have to add a line at the top of the file:

USE <database-name-here>;

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