Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calculate percentage column help!!

Author  Topic 

olud
Starting Member

6 Posts

Posted - 2003-04-23 : 08:17:23
Would someone please help me out here as i am pulling my hair out on this one.
I have used the code below to create a of a table in an sql2000 database

create view dbo.win AS
SELECT ' AST' AS TypeOfPost, COUNT(*) AS Total
FROM dbo.LTV_TypeOfPost
WHERE (TypeOfPost = 'AST') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')
UNION ALL
SELECT ' Deputy Head Teacher' AS TypeOfPost, COUNT(*) AS Total
FROM dbo.LTV_TypeOfPost
WHERE (TypeOfPost = 'Deputy Head Teacher') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')
UNION ALL
SELECT 'Head Teacher' AS TypeOfPost, COUNT(*) AS Total
FROM dbo.LTV_TypeOfPost
WHERE (TypeOfPost = 'Head Teacher') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')

the above code creates the following view;

TypeOfPost ----------------------------Total
AST -------------------------------------1
Deputy Head Teacher--------------------- 3
Head teache -----------------------------7


My problem is that i would like to create an additional column in the view/table that will calculate the percentage (%) for each row eg

TypeOfPost ------------Total --------------Percentage
AST ---------------------1 ------------------9.09%
Deputy Head Teacher -----3 ------------------27.27%
Head teache -------------7 ------------------63.63%

Thanks in advance for your help

Olud

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-04-23 : 08:28:24
Cross Post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25626

Go to Top of Page
   

- Advertisement -