Case Statement on an Inline View


Case Statement on an Inline View

Hi All,

I have a problem that looks weird to me and don't understand why that happens. I have a query which has 2 sets of computations from a table.

The first set of computations is an inline view that aggregates the data and also does some column computations and the outer query uses a case statement to read data from the inline view and sets column values.

The issue that I have is that each time I run the query, I get different values in the rows. The SUM(values) across the rows is always the same but the individual row values are never the same.

I then created a table for the inline view and then use the outer case statement to read from this table. Now I get the same values all the time. Why would this happen? I would have expected the values to change even after reading from a table instead or the values to be the same all the time when read from an inline view

Can anyone please help me understand this?

Thanks in advance,


Junior Contributor

Re: Case Statement on an Inline View

Hi Haarish,

could you show the SQL? 

Is there any RANDOM/SAMPLE/OLAP function in the Derived Table?