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