Re: Query to get Percentages

From: Dave Mausner <dmausner_at_brauntech>
Date: Fri, 1 Jul 1994 13:32:00 GMT
Message-ID: <1994Jul1.133200.6038_at_nntpxfer.psi.com>


In article <1994Jun28.174755.8671_at_ctp.com>, abhat_at_ctp.com (Anju Bhatnagar) says:
>I need to write a query that will generate a report of the type:
>
>Vendor Problem Total Number Percentage of Complaints that
> of Complaints need a followup (followup = 'Y')
>------ ------- ------------- ---------------------------------

to select a percentage, you must first know the total number of rows. do this first:

column count new_val kount
select count(*) count from complaints;

this creates a "def" variable which contains the count; now you are ready to calculate percentages:

select vendor,problem,count(*),100*count(*)/&kount from complaints group by vendor,problem;

--
Dave Mausner, Senior Consultant, Braun Technology Group, Chicago.
Received on Fri Jul 01 1994 - 15:32:00 CEST

Original text of this message