문제

My query is:

select 
    C.GradePoint, D.Domain
from
    (select 
         A.course_code, B.course_title, A.GradePoint
     from
         (select 
              course_code, GradePoint
          from 
              CoursesResult$
          where 
              roll_number = '42472' and GradePoint != 'I' 
              and GradePoint != 'F' and GradePoint != 'D-' 
              and GradePoint != 'D+' and GradePoint != 'D'
              and GradePoint != 'C-' and GradePoint != 'C'
              and GradePoint != 'C+') A  
     join Courses$ B on A.course_code=B.course_code) C 
     join Domains$ D on C.course_title=D.Courses

Output:

GradePoint         Domain
1.    B+        Software Developer
2.    B-        Software Developer
3.    B-        Software Developer
4.    B-        Project Management
5.    B-        Business Intelligence and Analytics
6.    B+        Business Intelligence and Analytics
7.    B+        Business Intelligence and Analytics
8.    B-        Game Development
9.    B             Game Development
10.    B-       Database Administrator
11.    B-       Database Administrator
12.    B        Database Administrator

now number for each grade is

  1. B=3
  2. B+ =4
  3. B- = 2

I want to calculate the count of grades for each domain

Needed output:

  1. Software Developer 8
  2. Business Intelligence and Analytics 10
  3. Database Administrator 7
  4. and so on

Can anyone help??

도움이 되었습니까?

해결책

replace your first two lines with this:

select 
SUM(CASE C.GradePoint WHEN 'B' THEN 3 WHEN 'B+' THEN 4 WHEN 'B-' THEN 2 ELSE 0 END), 
D.Domain

And add GROUP BY D.Domain at the very end of the query

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top