0
votes

The following formula is used in a column in Excel:

=IF(Variable_X(activecell)=Variable_X(cell directly above),IF(AND(Variable_Y(activecell)<>Variable_Y(cell directly above),ActualStartDate(activecell)<>0,FileDate(activecell)>=ActualStartDate(activecell)),1,0),"N")

I am really new to SQL and am wondering if this is possible as a SQL query where I would create a new column, and this formula would populate each cell in the column.

Variable_X and Variable_Y are two columns with respective values.

Thank you!

1

1 Answers

1
votes

You would want to use a CASE statement in SQL. Something along the lines of:

CASE WHEN variablex * activecell = variabley * activecell
AND Variable_Y * activecell != Variable_Y * cell directly above 
AND ActualStartDate * activecell != 0
AND FileDate * activecell >= ActualStartDate * activecell 
THEN 1
ELSE 0
END AS N

A CASE statement can be used almost identically like an IF statement in EXCEL.