A sımple questıon

General
Fan

A sımple questıon

Hi guys,

how can i provide this sql to return the B column value as 3. I want to use the column K in the current row although it is also in table.

In fact I will use the solution in a recursive query. In recursive query i want to use the new value of related column not the previous one for the next iteration.

Thanks.

SEL SUBSTR(K,1,3) K , LENGTH(K) B

FROM

(

SELECT 'KKKKK' K,'MMMM'M

)Q

3 REPLIES
Senior Apprentice

Re: A sımple questıon

Simply name it differently.

When there's a column and an alias with the same name the parser assumes the query it's referencing the column and not the alias.

SEL SUBSTR(K,1,3) newK , LENGTH(newK) B
FROM
(
SELECT 'KKKKK' K,'MMMM'M
)Q
Fan

Re: A sımple questıon

I have to use the same name  for the new column value. Cant i distinguish the new column K and "Q.K" with something like "this.K" :). Is there a function to handle this case.

SEL SUBSTR(K,1,3) K , LENGTH(this.K) B

FROM

(

SELECT 'KKKKK' K,'MMMM'M

)Q

Senior Apprentice

Re: A sımple questıon

No, you can't do that.

But why do you think you need it?

Within a recursive query you can simply apply the new name and still have the output name as defined.