|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I need to do a query that returns how many estudents are in each grade of a school, this is my query:
select decode(grade.order,11,count(axgs.cuser),null) "1º",decode(grade.iorder,12,count(axgs.cuser),null)"2º",decode(grade.iorder,13,count(axgs.cuser),null) "3º",decode(grado.iorder,14,count(axgs.cuser),null) "4º" from pro_grades grade,pro_students_x_grades_seccion axgs,pro_school schoolwhere school.cschool=559 and grade.cschool=school.cschool and axgs.cgrade=grade.cgrade group by grade.iorder; This is the result: 1º 2º 3º 4º ---------- ---------- ---------- ---------- - 15 15 7 15 The result is what i want but i need the numbers to be in just one row, something like: 1º 2º 3º 4º ---------- ---------- ---------- ---------- - 15 15 7 15 Probably is easy but i can`t figure out how to do it,thanks fot the help!! PD: The results in the first table are in diagonal |
|
#2
|
|||
|
|||
|
woops misread, I think this should do what you want:
PHP Code:
it builds a tally with the decode and then adds it up with the sum Last edited by hedge : September 3rd, 2003 at 04:16 PM. |
|
#3
|
|||
|
|||
|
I can`t, if i do that i have this error ORA-00937: not a single-group group function
|
|
#4
|
|||
|
|||
|
It works! Thanks a lot!
|
|
#5
|
|||
|
|||
|
good, BTW this probably should have been posted to the Oracle board
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > problem with decode and group by |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|