Hi @Kalbubu
There is no DATE function in T-SQL. You may use CONVERT or CAST to convert an expression of one data type to another.
Regarding the quotes, try this:
select * from openquery
(DWH_medw1,
'SELECT activity.the_date AS Activity_Date, LOWER(tag.name) AS tag_name,
count(activity.id) AS record_count
FROM agencies.activity_activity AS activity
INNER JOIN agencies.activity_activity_tags AS connection
ON activity.id = connection.activity_id
INNER JOIN agencies.activity_activitytag AS tag
ON connection.activitytag_id = tag.id
WHERE activity.franchisor_id IN (48, 61)
AND the_date >= ''2023-01-01''
AND (
LOWER(tag.name) LIKE ''%end of life care%''
OR LOWER(tag.name) LIKE ''%hospital discharge%''
OR LOWER(tag.name) LIKE ''%decline in mental ability%''
OR LOWER(tag.name) LIKE ''%fall prevention%''
OR LOWER(tag.name) LIKE ''%non-medical companion%''
)
GROUP BY activity.the_date, LOWER(tag.name)')
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.