w3resource

AdventureWorks Database: Concatenate character and date data types

SQL Query - AdventureWorks: Exercise-191 with Solution

191. From the following table write a query in SQL to concatenate character and date data types for the order ID 50001.

Sample table: sales.salesorderheader


Click to view Full table

Sample Solution:

SELECT concat('The order is due on ' , cast(DueDate as VARCHAR(12)))  
FROM Sales.SalesOrderHeader  
WHERE SalesOrderID = 50001;

Sample Output:

concat                          |
--------------------------------+
The order is due on 2013-03-22 0|

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Find credit cards that starting with 1 and the third digit is 6.
Next: Form one long string to display the last and first name.


What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.

SQL: Tips of the Day

ROW_NUMBER() in MySQL

SELECT t0.col3
FROM table AS t0
LEFT JOIN table AS t1 ON t0.col1=t1.col1 AND t0.col2=t1.col2 AND t1.col3>t0.col3
WHERE t1.col1 IS NULL;

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