Countymnca
Technical User
Hello,
I am having a very hard time trying to get a problem resolved. I am pretty sure a CASE Statement is what I need to use in the WHERE clause of my Query, but I am not getting it to work. Below is an explaination of what I need to the query to do.
I work for a pretty large organization and am moving various rosters and phone lists into a web app. Each of our various offices existing in a LOCATIONS table including the headquarters. I can pass the @currentuserID into the Where statement to limit the results to just employees or numbers at the officer where that employee works. The problem is I would like to have the same sp return all of the offices information when someone at headquarters runs the report. My query looks like:
SELECT A,B,C,.....
From Personnel
WHERE Office_ID IN (Select Office_ID from Personnel where @currentuserID = Personnel.EmployeeID)
I can also get it to work by passing the Office Name into the query and using LIKE (Select....)
The Office_ID of those assigned to headquarters is 17 so I thought maybe something with 17 as the ELSE result would work, but so far no luck.
I will admit to 0 experience with the CASE Statement as I come from the Access world and am use to IF, THEN and ELSE function.
Any suggestions or assistance would be greatly appreciated. If this is possible, I can use this statement as almost another rights level and that would be amazing.
I am having a very hard time trying to get a problem resolved. I am pretty sure a CASE Statement is what I need to use in the WHERE clause of my Query, but I am not getting it to work. Below is an explaination of what I need to the query to do.
I work for a pretty large organization and am moving various rosters and phone lists into a web app. Each of our various offices existing in a LOCATIONS table including the headquarters. I can pass the @currentuserID into the Where statement to limit the results to just employees or numbers at the officer where that employee works. The problem is I would like to have the same sp return all of the offices information when someone at headquarters runs the report. My query looks like:
SELECT A,B,C,.....
From Personnel
WHERE Office_ID IN (Select Office_ID from Personnel where @currentuserID = Personnel.EmployeeID)
I can also get it to work by passing the Office Name into the query and using LIKE (Select....)
The Office_ID of those assigned to headquarters is 17 so I thought maybe something with 17 as the ELSE result would work, but so far no luck.
I will admit to 0 experience with the CASE Statement as I come from the Access world and am use to IF, THEN and ELSE function.
Any suggestions or assistance would be greatly appreciated. If this is possible, I can use this statement as almost another rights level and that would be amazing.