I currently have two separate queries in SQL Server that count the number of times a table contains a unique ID in a week. I would like to display these using one query, not two.
This data is held in two separate views, hence my writing two queries. These are ActivityPointer and Asp_dealercallreport.
Query #1:
SELECT
OwnerIDName,
COUNT(Distinct ActivityID) AS CalendarEvents
FROM
ActivityPointer
WHERE
/*Specify Activity code for Calendar Events*/
ActivityTypeCode = '4201'
/*Specify Calendar Events from this week only*/
AND ScheduledStart >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) / 7 * 7, 0)
AND ScheduledStart <= DATEADD(DAY, DATEDIFF(DAY, -1, GETDATE()), 0)
/*Specify users to be reported on by Name*/
AND OwnerIdName IN ('John Doe', 'Jane Doe')
GROUP BY
OwnerIDName
Query #2:
SELECT
OwnerIDName,
COUNT(Distinct Asp_dealercallreportId) AS DealerVisits
FROM
Asp_dealercallreport
/*Specify Calendar Events from this week only*/
WHERE
asp_callreportdate >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) / 7 * 7, 0)
AND asp_callreportdate <= DATEADD(DAY, DATEDIFF(DAY, -1, GETDATE()), 0)
/*Specify to be reported on by Name*/
AND OwnerIdName IN ('John Doe', 'Jane Doe')
GROUP BY
OwnerIDName
Thanks