Subject | Re: case alias |
---|---|
Author | totako_tr |
Post date | 2005-05-02T12:16:32Z |
hi,
i need to both of the fields one by one. And another more ones.
This is only an example. I use more complex statement. i want to
abbreviate my sql. If i can define alias to "case" statement it will
be quite shorten for me...
i need to both of the fields one by one. And another more ones.
This is only an example. I use more complex statement. i want to
abbreviate my sql. If i can define alias to "case" statement it will
be quite shorten for me...
> At 07:50 AM 30/04/2005 +0000, you wrote:end)
> >hi all;
> >
> >in my sql i use "case when"
> >
> > case when a.f1 = 0 then 'zero' else 'not zero' end as TTT
> >
> >i want to use this result of case in another field
> >I must write again "case" statement..
> >
> >"Select case when a.f1 = 0 then 'zero' else 'not zero' end as TTT,
> >'Result = ' || (case when a.f1 = 0 then 'zero' else 'not zero'
> >from xTbl"TTT,
> >
> >but i don't want use it like this.. When i've a lot of "case"
> >statements my sql is growing..
> >
> >I want like this..
> > "Select case when a.f1 = 0 then 'zero' else 'not zero' end as
> > 'Result = ' || TTT from xTbl"second one,
> >
> >can I do it?
>
> Do you need both of these derived fields? If you just want the
> you could do this:xTbl" fits
>
> Select case
> when a.f1 = 0 then 'Result = ' || 'zero from xTbl'
> else 'Result = ' || 'not zero from xTbl' end as TTT,
>
> I can't tell from your description quite where the phrase "from
> in, but you get the idea.
>
> ./heLen