Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MacGyver
Starting Member
1 Post |
Posted - 2006-08-16 : 11:08:22
|
| Hi,This is the querey I have put in:SQL> select p.playername, count(g.goalscorerID) as GOALS 2 from tvs.players p, tvs.goals g 3 where p.playerID = g.goalscorerID 4 group by p.playername;Output :PLAYERNAME GOALS------------------------------ ---------------Thierry Henry 4Lionel Messie 1Samuel Eto 5Zidane 1Ronaldhino 2Ronaldo 5And now what I want to do is use the MAX() function to list the top scorers, so it would look like this.PLAYERNAME GOALS------------------------------ ---------------Ronaldhino 5Ronaldo 5I am having trouble doing this, this is one of the queries I have tried .SQL> select c.customername, count(v.soldto) as Borrowcount 2 from tvs.customer c, tvs.video v 3 where c.customerid = v.soldto 4 group by c.customername 5 having max(Borrowcount);So does anyone know how to do this?Thanks in advance for any input. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-08-16 : 11:12:45
|
select customername, max(Borrowcount) as MaxBorrowcountfrom (your group by query here) tgroup by customernameorder by 2Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|
|