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.
| 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 databasecreate view dbo.win ASSELECT ' AST' AS TypeOfPost, COUNT(*) AS TotalFROM dbo.LTV_TypeOfPostWHERE (TypeOfPost = 'AST') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')UNION ALLSELECT ' Deputy Head Teacher' AS TypeOfPost, COUNT(*) AS TotalFROM dbo.LTV_TypeOfPostWHERE (TypeOfPost = 'Deputy Head Teacher') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')UNION ALLSELECT 'Head Teacher' AS TypeOfPost, COUNT(*) AS TotalFROM dbo.LTV_TypeOfPostWHERE (TypeOfPost = 'Head Teacher') AND (TypeOfSchool = 'Primary') AND (Lea = 'Barking and Dagenham')the above code creates the following view;TypeOfPost ----------------------------TotalAST -------------------------------------1Deputy Head Teacher--------------------- 3Head teache -----------------------------7My problem is that i would like to create an additional column in the view/table that will calculate the percentage (%) for each row egTypeOfPost ------------Total --------------PercentageAST ---------------------1 ------------------9.09% Deputy Head Teacher -----3 ------------------27.27%Head teache -------------7 ------------------63.63%Thanks in advance for your helpOlud |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
|
|
|
|
|