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
Post a Comment