I have a query that need to filter data based on 4 input parameter supplied to the stored procedure.
The parameters are
Board_id, class_id, subject_id,exam_category_id
If board_id >-1 and remaining of the parameters are not -1, then
the board_id criteria in the where clause should be used.
ie if my query is
SELECT * FROM EXAM_RESULTS_VIEW
SUBJECT_ID = @SUBJECT_ID AND
CLASS_ID = @CLASS_ID AND
BOARD_ID = @BOARD_ID AND
EXAM_CATEGORY_ID = @EXAM_CATEGORY_ID
Is there a way i could do it to see if the where clause criteria uses only if the value of any parameter is greater than -1
to illustrate it further,
if class_id=2 and board_id=1 and subject_id=-1 and exam_category_id=-1
then the query should use on the Board_ID and Class_ID to filter the data based on the data supplied.