![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I'm using Ingres 9.0.4 and have the following table (I've simplified this to make it easier to explain): create table students (student_id char(6) not null with default, module_id char(6) not null with default, stud_status char(1) not null with default) stud_status has values of A,B + C. I want to compose a query to give me a count of students on the module and how many at each status. e.g. Module Total Count A Count B Count C Count T101 50 25 10 15 A444 120 65 44 11 |
#3
| |||
| |||
|
|
select module_id, count(*) as total_count, sum(case when stud_status = 'A' then 1 else 0 end) as a_count, ... repeat for b and c from students group by module_id I haven't tried this but it ought to work. Karl |
![]() |
| Thread Tools | |
| Display Modes | |
| |