To be honest, I have tried searching the internet and have not found a way to achieve this. So am hoping Stackoverflow might be able to help here. Am open to options (parameterization, use of VBA, etc etc). I don't want to create multiple queries that might grow each month due to this.
I will be getting multiple tables each month and I have to use the same query to fetch from these new tables and I don't want to change my query each time or write a new one each time. The query is something like this (I have tried to anomalize the names of APIs endpoints or the department):
SELECT MyDeptAprilLogs.apiproxy, Sum(MyDeptAprilLogs.sum_message_count) AS SumOfsum_message_count
FROM MyDeptAprilLogs <--- This is variable & so, must be a parameter (won't know until I get it)
GROUP BY MyDeptAprilLogs.apiproxy, MyDeptAprilLogs.response_status_code
HAVING (((MyDeptAprilLogs.apiproxy)="MyDept-MyAPI-Endpoint1-v6" Or
(MyDeptAprilLogs.apiproxy)="MyDept-MyAPI-Endpoint2-v5" Or
(MyDeptAprilLogs.apiproxy)="MyDept-MyAPI-Endpoint3-v6") AND
((MyDeptAprilLogs.response_status_code)=200));