LoslegenKostenlos loslegen

Working with DATEFROMPARTS()

In this lesson, you also learned how to combine different parts of a date, which are in separate columns into one.

In the paper_shop_daily_sales table, the columns year_of_sale, month_of_sale, and day_of_sale, store the different values of a date.

| product_name | units | year_of_sale | month_of_sale | day_of_sale |
|--------------|-------|--------------|---------------|-------------|
| notebooks    | 2     | 2019         | 1             | 1           |
| notebooks    | 3     | 2019         | 5             | 12          |
| ...          | ...   | ...          | ...           | ...         |

You need to combine all these columns into one, by using the DATEFROMPARTS() function.

Diese Übung ist Teil des Kurses

Cleaning Data in SQL Server Databases

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

SELECT 
	product_name,
	units,
    -- Use the function to concatenate the different parts of the date
	___(
      	___, 
      	month_of_sale, 
      	___) AS complete_date
FROM paper_shop_daily_sales
Code bearbeiten und ausführen