Below is my where clause of the query when i want data for a specific user
where Completion_Date>= '11/01/2011'
and Completion_Date<= '12/11/2012'
and System_user_id = 1234
and below is the where clause when i want to pull data for all the user:
where Completion_Date>= '11/01/2011'
and Completion_Date<= '12/11/2012'
Since i dont want 2 seperate queries, is there a way to add a condition in where clause so that i can use a single query and depending on the input (i.e System_user_id) it will decide on whether to add extra condtion in the query.
I will be sending -1 when i want data for all users & for a specific user its system_user_id will be sent.
You may try the following procedure.
Updated Query
Results:
To see a specific user:
ANOTHER METHOD
Updated after latest comment from OP
Query:
Results: when @uid = -1
Please comment if you have tried this out 🙂