Marin
Marin

Reputation: 69

Cognos LIKE function problems

I am facing a problem on Cognos 10 with the LIKE function. I have a varchar field named EOM_DATE which contains the end of months values, for example: 2017_01, 2017_02, etc.

I want to build a query like this:

[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE ('2016%', '2017%', '2018%')

because I want that only the specified years to show.

Any solution? I have tried different solutions using LIKE, STARTS WITH and even IN, but none of them seems to work.

Upvotes: 0

Views: 2959

Answers (1)

Johnsonium
Johnsonium

Reputation: 2005

You have to break it out. The pattern you are using only works with IN and IN doesn't support wildcards.

Try this:

[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2016%'
OR
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2017%'
OR
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2018%'

This is effectively a long-form of IN, but it allows you to use the LIKE operator.

Upvotes: 1

Related Questions