Skip to content
Advertisement

Difficulty filtering by Select Column

I’m going to apologize in advance. I basically stumble through SQL as projects need done but my knowledge is rather lacking, so I apologize for any incorrect terminology or poor syntax. I would appreciate it if anyone would be able to help me out.

I have the following query.

I have also attached pics of the current Output and the Holiday Table that is being referenced.

My issue is that I would like to be able to filter my data to show any data that is 8 or 12 business days out, however, I am unable to pull through the column name or have SQL recognize the BusinessDaysUntil column.

Would someone be able to help me out? Once I get this squared away, the rest of the project should go smoothly.

Advertisement

Answer

You can’t use a derived column in the WHERE clause.
Also you are using a rather useless CTE which returns only 1 column of the table SampleDB.
Instead create a CTE with the query and then select from it and filter:

Replace BusinessDaysUntil > ? with the filter that you want to apply.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement