Help with percentage

  • Hi I need help with calculating a percentage.

    I have a query like so

    select gender, ee_occup_levels, [African], [Coloured], [Indian], [White]

    from (select ee_occup_levels, gender, race, staffno

    from dtiheadcount inner join reportingstructure

    on dtiheadcount.costcenter = reportingstructure.costcenter

    where (period = 200909)

    and (dtiheadcount.headcount = 'headcount')

    and (dtiheadcount.hccat2 = 'permanent')

    and (dtiheadcount.staffno is not null)) AS x

    Pivot (Count(staffno) for Race in ([African], [Coloured], [Indian], [White])) as pvt

    I need to devide the number in the column with the the total sum of female and male.

  • declare a variable, get your total into that variable and then divide each column in the select with the variable something like this,

    Declare @max-2 as float

    Set @max-2 = 200 -- << get the sum from yourtable>>

    Select (column/@max)*100 from yourtable

    This wont do?

    ---------------------------------------------------------------------------------

  • Great. Thanks will do

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply