Home » Developer & Programmer » Reports & Discoverer » Count (A+,A,B) from grade column (6i,Oracle,9i Rel.2)
|
|
Re: Count (A+,A,B) from grade column [message #625755 is a reply to message #625739] |
Mon, 13 October 2014 22:35 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
1 Select decode( 'E', '33-39',
2 'D', '40-49',
3 'C', '50-59',
4 'B', '60-69',
5 'A', '70-79',
6 'A+','80% and above'
7 ),count(tstuid) from test1
8 group by decode( 'E', '33-39',
9 'D', '40-49',
10 'C', '50-59',
11 'B', '60-69',
12 'A', '70-79',
13 'A+','80% and above'
14* )
SQL> /
DECODE('E','3 COUNT(TSTUID)
------------- -------------
80% and above 28000
|
|
|
|
Re: Count (A+,A,B) from grade column [message #625804 is a reply to message #625787] |
Tue, 14 October 2014 06:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
Select decode(grade, 'E', '33-39',
2 'D', '40-49',
3 'C', '50-59',
4 'B', '60-69',
5 'A', '70-79',
6 'A+','80% and above'
7 ),count(tstuid) from test1
8 group by decode(grade, 'E', '33-39',
9 'D', '40-49',
10 'C', '50-59',
11 'B', '60-69',
12 'A', '70-79',
13 'A+','80% and above'
14 )
/
my grade is calculation of formula column.
function GRADEFormula return Char is
begin
IF :CF_1>= 80 THEN
RETURN('A+');
ELSIF :CF_1 >= 70 AND :CF_1 <= 79 THEN
RETURN('A');
ELSIF :CF_1 >= 60 AND :CF_1 <= 69 THEN
RETURN('B');
ELSIF :CF_1 >= 50 AND :CF_1 <= 59 THEN
RETURN('C');
ELSIF :CF_1 >= 40 AND :CF_1 <= 49 THEN
RETURN('D');
ELSIF :CF_1 >= 33 AND :CF_1 <= 39 THEN
RETURN('E');
ELSE
RETURN('F');
END IF;
end;
please advised.
|
|
|
|
|
|
Re: Count (A+,A,B) from grade column [message #625810 is a reply to message #625809] |
Tue, 14 October 2014 07:08 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
In fact does test1 even have a grade column? It doesn't in your other thread.
Rememeber we don't know anything about your tables or your report other than what you tell us.
We don't know how grade is calculated or where it's stored.
|
|
|
Re: Count (A+,A,B) from grade column [message #625816 is a reply to message #625810] |
Tue, 14 October 2014 07:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
SQL> desc test
Name Null? Type
----------------------------------------- -------- -------------------
TID NOT NULL NUMBER(9)
TDATE NOT NULL DATE
CLASS VARCHAR2(30)
EXAMC VARCHAR2(80)
SUBJECT VARCHAR2(70)
TOTMARKS NUMBER(3)
SEC VARCHAR2(50)
SQL> desc test1
Name Null? Type
----------------------------------------- -------- ------------------------
TID NUMBER(9)
TDATE DATE
TSTUID NUMBER(7)
OBTMARKS NUMBER(5,2)
PERCT NUMBER(6,2)
REMARK VARCHAR2(300)
function CF_1Formula return Number is
begin
RETURN(Round((NVL(:Sumobtmarks,0)/NVL(:Sumtotmarks,0))*100));
end;
function GRADEFormula return Char is
begin
IF :CF_1>= 80 THEN
RETURN('A+');
ELSIF :CF_1 >= 70 AND :CF_1 <= 79 THEN
RETURN('A');
ELSIF :CF_1 >= 60 AND :CF_1 <= 69 THEN
RETURN('B');
ELSIF :CF_1 >= 50 AND :CF_1 <= 59 THEN
RETURN('C');
ELSIF :CF_1 >= 40 AND :CF_1 <= 49 THEN
RETURN('D');
ELSIF :CF_1 >= 33 AND :CF_1 <= 39 THEN
RETURN('E');
ELSE
RETURN('F');
END IF;
end;
|
|
|
Re: Count (A+,A,B) from grade column [message #625820 is a reply to message #625816] |
Tue, 14 October 2014 07:58 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Trouble here is you've given us some formula columns, but not all of them and we don't know how they relate to the main report query.
If all the calculations were in the main report query then you could just post that and we could see what you're doing.
They're not though, so you're going to have to write some sentences to explain the relationship.
This can be done in a single query - and should, formula and summary columns won't make it any easier.
It will be of the form:
SELECT grade, count(*)
FROM (select student_id, <calculation of grade>
from .....
where .....
)
group by grade
|
|
|
|
Re: Count (A+,A,B) from grade column [message #625825 is a reply to message #625824] |
Tue, 14 October 2014 08:34 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
More sentences, less pictures please. We had this conversation on the last reports thread.
What is Sumobtmarks and Sumtotmarks (which doesn't appear to be in the above screenshot).
But really you should be able to do this. You had to work out percentage per student in the last thread.
Do the same again (in a single query), convert percentage to grade, then apply it to my example structure above.
|
|
|
Re: Count (A+,A,B) from grade column [message #625839 is a reply to message #625825] |
Tue, 14 October 2014 21:31 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
select distinct :grade,count(*) from
(select stuid,:grade,examc,test.class,sec
from student,dual,test,test1
where student.status='PRESENT'
and test.class=:cls --(pick through Parameter Form)
and test.sec=:sess --(pick through Parameter Form)
and test.examc=:ty --(pick through Parameter Form)
group by :grade,stuid,examc,test.class,sec)
this query shows grade as null and count is equal to 0.grade is based on if condition as described in previous post.i want to show the grades on left and in each subject i want to count no of A+, A, B, C....and so on.
|
|
|
Re: Count (A+,A,B) from grade column [message #625866 is a reply to message #625839] |
Wed, 15 October 2014 02:52 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You can't use a bind variable like that. It'll only have one value for any given run of the query which is not what you need.
You need to calculate grade in the query, not try and refer to a pre-calculated grade item in the report.
|
|
|
|
Re: Count (A+,A,B) from grade column [message #625915 is a reply to message #625907] |
Thu, 16 October 2014 02:55 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
SELECT grade, count(*)
FROM (select student_id,
CASE WHEN percentage >= 80 THEN 'A+'
WHEN percentage >= 70 THEN 'A'
.....
END AS grade
from (SELECT student_id, SUM(obtmarks)/SUM(totmarks) AS percentage
FROM ....
WHERE .....
GROUP BY student_id
)
)
group by grade
Now spend some time thinking about it and fill in the blanks. It's not difficult.
|
|
|
Re: Count (A+,A,B) from grade column [message #626025 is a reply to message #625915] |
Sun, 19 October 2014 10:44 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
SELECT grade, count(*)
FROM (select stuid,
CASE WHEN perc >= 80 THEN 'A+'
WHEN perc between 70 and 79 THEN 'A'
WHEN perc between 60 and 69 THEN 'B'
WHEN perc between 50 and 59 THEN 'C'
WHEN perc between 40 and 49 THEN 'D'
WHEN perc between 33 and 39 THEN 'E'
WHEN perc < 33 THEN 'F'
END AS grade
from (SELECT stuId, SUM(obtmarks)/SUM(totmarks)*100 AS perc,EXAMC,SEC,TEST.CLASS
FROM TEST,TEST1,STUDENT,CLASS,SUB
where test.tid=test1.tid
and test.tdate=test1.tdate
and test.class=:cls
and test.sec=:ssec
and test1.tstuid=student.stuid
and student.STATUS='PRESENT'
and sub.subject=test.subject
and sub.cname=class.cname
and examc=:TY
group by TEST.class,examc,sec,stuid)
GROUP BY stuid,perc
)
group by grade
Out put is:
SQL> /
GR COUNT(*)
-- ----------
A 1
A+ 1
B 5
C 8
D 2
E 3
F 2
3
i want to count Also each subject grade please advised ...
|
|
|
|
|
|
Re: Count (A+,A,B) from grade column [message #626716 is a reply to message #626073] |
Fri, 31 October 2014 10:39 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shahzad-ul-hasan
Messages: 643 Registered: August 2002
|
Senior Member |
|
|
Sir
it shows the A (no of record of A+) and A+ (no of record of A).
SELECT grade, count(*)
FROM (select stuid,
CASE WHEN perc >= 80 THEN 'A+'
WHEN perc between 70 and 79 THEN 'A'
WHEN perc between 60 and 69 THEN 'B'
WHEN perc between 50 and 59 THEN 'C'
WHEN perc between 40 and 49 THEN 'D'
WHEN perc between 33 and 39 THEN 'E'
WHEN perc < 33 THEN 'F'
END AS grade
from (SELECT stuId, SUM(obtmarks)/SUM(totmarks)*100 AS perc,EXAMC,SEC,TEST.CLASS
FROM TEST,TEST1,STUDENT,CLASS,SUB
where test.tid=test1.tid
and test.tdate=test1.tdate
and test.class=:cls
and test.sec=:ssec
and test1.tstuid=student.stuid
and student.STATUS='PRESENT'
and sub.subject=test.subject
and sub.cname=class.cname
and examc=:TY
group by TEST.class,examc,sec,stuid)
GROUP BY stuid,perc
)
group by grade
|
|
|
|
Re: Count (A+,A,B) from grade column [message #626857 is a reply to message #626827] |
Tue, 04 November 2014 03:29 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Are you saying that the A+ row gives the count of students who got A and the A row gives the count of students that got A+?
If that's happening then most likely it's because your joins are wrong.
Or the above query is right and whatever you are comparing it to is wrong.
The obvious thing to do is remove the outer layer of the select so that you get stuid and grade. Then check if the students have the correct grade.
|
|
|
Goto Forum:
Current Time: Mon Feb 17 02:27:48 CST 2025
|