Question

This question is a little hard to word, so I'll show you what I need

CASE

WHEN t1.RANGE_START = t1.RANGE_END
    Then (select RANGE_START 
    from .dbo.t1

    )

END as Value

what I'm trying to do is make it so that if range start and range end are equal then just use the range start as the value for each row.

I understand that what the query is doing right now is trying to select every Range_start for each value where the range_start = range_end so how do I limit the sub query to only pull that value for the current row?

Was it helpful?

Solution

Kind of guessing without trying I am afraid but you can't be far away...something like this.

SELECT
  CASE 
     WHEN t1.RANGE_START = t1.RANGE_END 
        THEN t1.RANGE_START
       ELSE t1.RANGE_END
     END AS Value,
  column1,
  column2,
  column3
FROM dbo.t1

I usually find this resource pretty useful

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top