SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Calculating a percentage
-
Jun 3, 2004, 08:06 #1
- Join Date
- Mar 2000
- Location
- Muskegon, MI
- Posts
- 2,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Calculating a percentage
Is it possible to calculate a percentage within a query?
Normally, I would handle this by running a query and than do server-side calcualtions based on the results diveded by the total number of records returned.
Code:Select Count(Employee) as Total, Department From Employees Group By Department Order By Department
-
Jun 3, 2004, 08:09 #2
What would have to be in percentages? We need some more info on your database columns/datatypes/structure. Otherwise it's just simple arithmetic nested in your query that would get a percentage.
-
Jun 3, 2004, 08:10 #3
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
Originally Posted by westmich
Code:select count(Employee) as Total , count(Employee) * 100 / ( select count(Employee) from Employees ) as DeptPercent , Department from Employees group by Department order by Department
-
Jun 3, 2004, 08:21 #4
- Join Date
- Mar 2000
- Location
- Muskegon, MI
- Posts
- 2,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Awesome
Bookmarks