Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Pivot table
A copy of this was sent to "Ing. Martin Gamperl" <mgampi_at_ibm.net>
(if that email address didn't require changing)
On Sun, 19 Apr 1998 13:42:17 +0200, you wrote:
>Using Oracle 8.0.4 on Windows NT 4.0 I have a table with a structure
>like this:
>
> DT C1 C2 C3 C4 C5 C6
> -------------------------------------
> 01-15-98,00:00
> 01-15-98,00:01
> 01-15-98,00:02
> .....
>
>The table contains measured values with a sample rate of about 1 Minute.
>For statistics within a defined intervall (DT between lower and upper
>bound) I need a result which looks like this:
>
> COLUMN MEAN MIN MAX STDDEV SUM
> --------------------------------------------
> C1
> C2
> C3
> C4
>
>How can this be achieved with a SQL select statement?
>
select c1, min(c1), max(c1), stddev(c1), sum(c1) from T
group by c1
UNION ALL
select c2, min(c2), max(c2), stddev(c2), sum(c2) from T
group by c2
...
UNION ALL
select c4, min(c4), max(c4), stddev(c4), sum(c4) from T
group by c4
btw: computing the MEAN with SQL will be very difficult at best...
>Thanx in advance
>
>Martin
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sun Apr 19 1998 - 13:24:01 CDT
![]() |
![]() |