```
ALTER PROCEDURE GetVendor_RMA_CreditMemo
    (@HasCreditMemoNo INT)
BEGIN
    SELECT 
        * 
    FROM
        (SELECT
             CreditMemoNumber,
             CASE WHEN CreditMemoNumber != '' 
                     THEN 1
                     ELSE 0 
             END AS HasCreditMemoNo   
         FROM
             XYZ) as C
    WHERE
        (C.HasCreditMemoNo = @HasCreditMemoNo OR @HasCreditMemoNo = -1)
END 

```

`CreditMemoNumber` is a `varchar` column

I want to achieve this:

```
CASE 
   WHEN @HasCreditMemoNo = 0 
      THEN -- select all rows with no value in CreditMemoNumber Column,  
   WHEN @HasCreditMemoNo = 1 
      THEN -- all rows that has some data,   
   WHEN @HasCreditMemoNo = -1 
      THEN -- everything regardless..

```