0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Trent- thanks so much for your help! I will give that a try and play around with how to make it exactly what I need. Thanks for explaining the Case comparison to IF. I use VBA quite a bit so it's nice to understand how they are alike.
Just a note: variablex * activecell = variabley * activecell is the same as variablex = variabley.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.