Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help: SELECT STATEMENT
select switch,
sum(decode(position,'On',1,0)) "On", sum(decode(position,'Off',1,0)) "Off"from t
--
Have a nice day
Michel
JagMan <jagman98_at_home.com> a écrit dans le message :
38CD9D7D.F0C4735F_at_home.com...
> I have following table:
>
> Switch-colum position-column Time
> switchA On 1:00
> switchA Off 2:00
> switchD On 1:00
> switchB Off 1:00
> switchD Off 2:00
> switchC Off 1:00
> switchC Off 2:00
> =============================
> I need following output:
>
> Switch On-Total Off-Total
> switchA 1 1
> SwitchB 0 1
> SwitchC 0 2
> SwitchD 1 1
> ==============================
> As above the output is grouped by Switch column. I can't figure out how
> to split position-column into "on-total' and "off-total" colums using
> SELECT statement.
>
> Thanks in advance!
> Manny
>
Received on Tue Mar 14 2000 - 02:39:26 CST