Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL Statement problem
If you don't know the groups ahead of time this will work:
SELECT
t1.cat_type, t1.count_of_type/t3.total as PCT FROM (SELECT t2.cat_type, count(*) count_of_type FROM workload t2 GROUP BY t2.cat_type) t1, (SELECT count(*) total FROM workload t4) t3 --Cartesian join intended
-Peter
On Wed, 10 May 2000 emaus081269_at_my-deja.com wrote:
> What if you don't know the name of the field. It comes from the
> database?
>
> In article <Pine.OSF.4.21.0005101058310.13581-100000_at_wpi.WPI.EDU>,
> Peter Connolly <peter_at_wpi.edu> wrote:
> > The following will do it assuming you know the category types ahead of
> > time:
> >
> > SELECT
> > sum(decode(w.cat_type,'TRAINING',1,0))/count(*) as
PCT_TRAINING,
> > sum(decode(w.cat_type,'TECHNICAL',1,0))/count(*) as
PCT_TECHNICAL,
> > ...
> > FROM
> > workload w
> >
> > On Wed, 10 May 2000, miike wrote:
> >
> > > I have a table (workload) that has a column (category_type) that
has 5
> > > different possible entries(training, technical, clerical,
operations,
> > > supply). Is there a way to write a SQL statement to get a listing by
> > > percentage of each entry type (i.e. training =25%, technical=30%,
etc)
> > > so that I can create a piechart to give my supervisor?
> > > TIA.
> > > -mike-
> > >
> > >
> >
> >
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Received on Wed May 10 2000 - 00:00:00 CDT
![]() |
![]() |