AdventureWorks Database: Add two days to each value in the OrderDate column
SQL Query - AdventureWorks: Exercise-113 with Solution
113. From the following table write a query in SQL to add two days to each value in the OrderDate column, to derive a new column named PromisedShipDate. Return salesorderid, orderdate, and promisedshipdate column.
Sample table: sales.salesorderheader
Sample Solution:
SELECT SalesOrderID
,OrderDate
,OrderDate + INTERVAL '2 day' AS PromisedShipDate
FROM Sales.SalesOrderHeader;
Sample Output:
salesorderid|orderdate |promisedshipdate | ------------+-----------------------+-----------------------+ 43659|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43660|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43661|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43662|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43663|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43664|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43665|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43666|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43667|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43668|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| 43669|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000| ...
SQL AdventureWorks Editor:
Practice Online
Contribute your code and comments through Disqus.
Previous: Obtain the salary percentile of each employee for a department.
Next: Get a newdate by adding two days with current date.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join