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

SQL Server Copilot AI

 Here are some of the latest tips and advanced concepts for Microsoft SQL Server (MS SQL) in 2024: 1. SQL Server Copilot AI Microsoft has in...