Question

I am using oracle sql and was having issues with the group by function. I've been reading similar questions about this issue but have been unable to solve my problem. For my problem, I have two tables [recruits (9), drill instructors(3)] and need to count the number of recruits (rid) for each drill instructor and display the drill instructors' f_name and l_name

I've tried a lot of variations of group by and order by. This was the last formula I used:

Select di.f_name, di.l_name, count(recruits.rid) 
from di, recruits 
where di.di_id=recruits.di_id 
group by recruits.rid;

Thank you in advance!

Was it helpful?

Solution

Try this

Select di.f_name, di.l_name, count(recruits.rid) 
from di, recruits 
where di.di_id=recruits.di_id 
group by di.f_name, di.l_name

Also, you can use the more current join syntax

Select di.f_name, di.l_name, count(recruits.rid) 
from di
join recruits on di.di_id=recruits.di_id 
group by di.f_name, di.l_name
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top