I suspect some like
select (select exp1 from t where exp1 is not null),
(select exp2 from t where exp2 is not null),
(select exp3 from t where exp3 is not null)
from
( Select
Exp1= <calculation>,
Exp2 = NULL,
Exp3 = NULL
From table 1
Where .
Union Select
Exp1 = NULL,
Exp2 = <calculation>,
Exp3 = NULL
From table 2
Where .
Union Select
Exp1 = NULL,
Exp2 = NULL,
Exp3 = <calculation>
From table 3
Where .
) t
will do what you want. The solution below will give three rows, with one
"exp" correctly calculated in each row.
hth,
Dave.
> -----Original Message-----
> From: Harry Jega Nathan [mailto:hjeganathan@y...]
> Sent: 09 January 2002 18:58
> To: sql language
> Subject: [sql_language] Re: Multiple SELECT statements in 1 row
>
>
> Mike,
> Try like this
> Select
> Exp1= <calculation>,
> Exp2 = 0,
> Exp3 = 0
> >From table 1
> Where .
> Union Select
> Exp1 = 0,
> Exp2 = <calculation>,
> Exp3 = 0
> >From table 2
> Where .
> Union Select
> Exp1 = 0,
> Exp2 = 0,
> Exp3 = <calculation>
> >From table 3
> Where .
>
>
>
> --- Mike Deck <MichaelBDeck@t...> wrote:
> > I am trying to write a stored proc that will return
> > the values of several
> > different expressions in one row. The problem is
> > each expression must be
> > evaluated based on different conditions in the WHERE
> > clause. I've tried
> > using a union but that gives me only one cloumn with
> > many rows. Any ideas
> > or solutions would be greatly appreciated.
> >
> >
> >
> > Thanks,
> > Mike
> $subst('Email.Unsub').
>
>
> ______________________________________________________________________
> Web-hosting solutions for home and business! http://website.yahoo.ca
>
> $subst('Email.Unsub').
>