oracle11g - Oracle SQL join three tables and group by column -


i have 3 tables , want query te select teacher names , number of classes each teacher has reserved.

teacher:

| idt | name | 

class:

| idc | name | 

reserve:

| idc | idt | 

my query:

select   t.name, count(distinct(r.idc))     teacher t   join    reserve r   on   r.idt = t.idt   join   class c   on   c.idc = r.idc   group r.idc 

when run followin error: not group expression.

the group by clause needs contain non-aggregated columns select statement; in case should t.name. also, distinct not function keyword , should not have parentheses.

select   t.name,    count(distinct r.idc) number_of_classes   teacher t join    reserve r on r.idt = t.idt join   class c on c.idc = r.idc group    t.name 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -