I want to find who is the heaviest borrower among the student and displaying Sname and heavy count.
I have the following tables.
tablename student having attributes SID,Sname,Spho.
tablename sborrow having attributes SID,CDID,borrow_date,return_date.
tablename Cd having attributes CDID,title.
I have executed the following query in Mysql but it gives me only the count properly and name as different.
Query->SELECT Sname,max(Quantity) as stud from (select Sname, count(CDID) as Quantity from student NATURAL JOIN sborrow group by SID) as stud;
please help me.......
Febel
0
Newbie Poster
Recommended Answers
Jump to Postnot tried but you may try
select SID, count() from student s, sborrow b
where s.SID = b.SID
group by s.SID
order by count() desc
limit 1
All 4 Replies
Mahesh57
0
Newbie Poster
Febel
0
Newbie Poster
Mahesh57
0
Newbie Poster
janissantony
15
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.