I am writing a query where I want to limit the number of rows heading into the when condition when using case when statement. For example, what I am trying to do is for any prod