9 Oct 2024

Time based welcome greetings

 SELECT

    CAST(TourDate AS DATE) as date ,
    EmployeeName AS Name,
    STRING_AGG(CONCAT(
	CASE
        WHEN CAST(DATEPART(HOUR, [TourDate]) AS INT) < 12 THEN 'Good Morning '
        WHEN CAST(DATEPART(HOUR, [TourDate]) AS INT) BETWEEN 12 AND 17 THEN 'Good Afternoon '
        ELSE 'Good Evening ' End +
	'From ', DeparturePlace, ' To ', ArrivalPlace), ', ')
        WITHIN GROUP (ORDER BY TourDate) AS VisitedPlace
FROM
    Tour
GROUP BY
    CAST(TourDate AS DATE), EmployeeName;

 

No comments:

Post a Comment

Top 10 SQL Skills You Need to Succeed in 2024

  Top 10 SQL Skills You Need to Succeed in 2024 To help you navigate the world of SQL and become a data-driven professional, we've ident...