Skip to main content
Solved

SQL 'Case'

  • January 22, 2020
  • 1 reply
  • 41 views

How to write 'case' in Custom SQL, please let me know with example.

Here is the situation (SQL query) that I need to perform on Date table & likes to update 'IND' column where DateValue is default column in Date table

select
case when GETDATE()<=DateValue then 'N' else 'Y' end as 'IND' ,* from <table_name> order by DateValue desc

Best answer by JTreadwell

Hi Sai, Thanks for posting! Do this: 

  1. Right click the table > Add Field > Name it 'IND'
  2. Right click the field > Add transformation > operator 'Fixed value', Value: 'Y' > Click Add
  3. Right click the field again > Add Transformation > operator 'Fixed value', Value: 'N' > Click Add
  4. Right click the 'Fixed Value: N' Transformation > Add Condition > In the condition pane, Operator: 'Custom Condition' > Click Add
  5. Type: "GETDATE()<=[DateValue]" > Click OK

You Should end up with something like this: 

 

View original
Did this topic help you find an answer to your question?

1 reply

JTreadwell
Employee
Forum|alt.badge.img+5
  • Employee
  • 179 replies
  • Answer
  • January 24, 2020

Hi Sai, Thanks for posting! Do this: 

  1. Right click the table > Add Field > Name it 'IND'
  2. Right click the field > Add transformation > operator 'Fixed value', Value: 'Y' > Click Add
  3. Right click the field again > Add Transformation > operator 'Fixed value', Value: 'N' > Click Add
  4. Right click the 'Fixed Value: N' Transformation > Add Condition > In the condition pane, Operator: 'Custom Condition' > Click Add
  5. Type: "GETDATE()<=[DateValue]" > Click OK

You Should end up with something like this: 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings