Write a SELECT statement that returns these columns from the Orders table: The o
ID: 3556516 • Letter: W
Question
Write a SELECT statement that returns these columns from the Orders table:
The order_id column
The order_date column
The ship_date column
A column named days_to_ship that shows the number of days between the order_date and the ship_date
Add a WHERE clause that retrieves just the orders for March 2012 with a shipping date.
Here is what I came up with on my own:
SELECT order_id, order_date,
ship_date, (ship_date - order_date) AS 'days_to_ship'
FROM orders
WHERE MONTH(ship_date) = '3'
AND YEAR(ship_date) = '2012';
Explanation / Answer
Your query seems correct. All you need to chance is the format of Month and year in where clause.
Since they are not strings we use do not use apostrophe's.
Please find the below code that should solve your issue.Change made to the bold font
SELECT order_id, order_date,
ship_date, (ship_date - order_date) AS 'days_to_ship'
FROM orders
WHERE MONTH(ship_date) = 3
AND YEAR(ship_date) = 2012;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.