I am trying to select the IDs based on period and type of account.Each account type would have a different period. I tried the following code but it didnt like the < operator
You're misunderstanding the case statement. What you have in your THEN clause is what is returned by the CASE statement (like an if... then... statement). The way you have it written, it returns a boolean.
Try this instead...
SELECT ID, Period, Type
FROM Table1
WHERE Type='ASSET' AND Period < @inputperiod
UNION
SELECT ID, Period, Type
FROM Table1
WHERE Type='Liability' AND Period BETWEEN @start AND @enddate
You can't use CASE
to swap out arbitrary bits of the query. You would need to use
SELECT ID, Period, Type
FROM TABLE1
WHERE (Type='ASSET' AND Period < @inputperiod )
OR (Type='Liability' AND Period BETWEEN @start AND @enddate)