Home » SQL & PL/SQL » SQL & PL/SQL » Calculate Percentage in SQL - URGENT PLEASE
Calculate Percentage in SQL - URGENT PLEASE [message #19786] Tue, 09 April 2002 17:52 Go to next message
Shekar
Messages: 25
Registered: August 2000
Junior Member
Could someone provide the sql query for the following
problem please?

Database:
TABLE TRANSCRIPT(student_ssn, d_code, c_no, grade);

question:
---------
For each course(combination of d_code and c_no) in the transcript table give the percentage of students who got grade 'A'.

Please reply with your sql query.

Thanks
- Shekar
Re: Calculate Percentage in SQL - URGENT PLEASE [message #19805 is a reply to message #19786] Wed, 10 April 2002 12:57 Go to previous message
sridhar
Messages: 119
Registered: December 2001
Senior Member
Try this,

SELECT b.course, round((cnt/total) * 100, 2) percentage
FROM
(Select count(*) total from TRANSCRIPT) a,
(Select count(*) cnt, d_code||c_no course from TRANSCRIPT WHERE grade = 'A'
Group By d_code||c_no course) b

Thanx,
SriDHAR
Previous Topic: please help!!
Next Topic: how to
Goto Forum:
  


Current Time: Sat May 04 17:43:55 CDT 2024