﻿ SQL - Order which will be delivered by a specified salesman

# SQL Exercises: Order which will be delivered by a specified salesman

## SQL Basic Select Statement: Exercise-11 with Solution.

From the following table, write a SQL query to find orders that are delivered by a salesperson with ID. 5001. Return ord_no, ord_date, purch_amt.

Sample table: orders

Sample Solution:

``````SELECT ord_no, ord_date, purch_amt
FROM orders
WHERE salesman_id=5001;``````

Output of the Query:

```ord_no	ord_date	purch_amt
70002	2012-10-05	65.26
70005	2012-07-27	2400.60
70008	2012-09-10	5760.00
70013	2012-04-25	3045.60
```

Code Explanation:

The given query in SQL that selects the "ord_no", "ord_date" and "purch_amt" columns from the 'orders' table where the value of "salesman_id" column is 5001. By using the WHERE clause, we filter the rows and only return the rows matching the condition.

Relational Algebra Expression:

Relational Algebra Tree:

Explanation:

Visual presentation :

## Query Visualization:

Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Select all columns that satisfy a specific condition.
Next SQL Exercise: Display the Nobel prizes for 1970.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

## SQL: Tips of the Day

What is the best way to paginate results in SQL Server?

```SELECT  *
FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, *
FROM      Orders
WHERE     OrderDate >= '1980-01-01'
) AS RowConstrainedResult
WHERE   RowNum >= 1
AND RowNum < 20
ORDER BY RowNum
```

Database: SQL Server

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

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook