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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query issue while using distinct and sum

Author  Topic 

madiaz
Starting Member

2 Posts

Posted - 2007-05-28 : 17:12:54
I am developing a web site for my buddies and I to track the winnings fom my home poker games.

Table that keeps track of games goes like:

PlayerID
PokerGameID
curWon

I want to sort by top money maker nd show total won to date

I have tried to use:

Select Distinct Sum(G.curWon) AS curCash, P.playerID FROM GameReults As G, Players As G WHERE G.PlayerID=G.PlayerID Group By G.curWon, G.PlayerID

I can not getit to sort from highet to lowest and it itrates through each record. I only want it to show distinct players and their winnings. Can you please help?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-28 : 20:51:41
[code]
Select Distinct Sum(G.curWon) AS curCash, P.playerID
FROM GameReults As G INNER JOIN Players As G P
WHERE ON G.PlayerID = G P.PlayerID
Group By G.curWon, G P.PlayerID
ORDER BY curCash DESC
[/code]


KH

Go to Top of Page

madiaz
Starting Member

2 Posts

Posted - 2007-06-02 : 00:01:21
Thanks, that did he trick.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-02 : 02:13:25
<<
I can not getit to sort from highet to lowest and it itrates through each record. I only want it to show distinct players and their winnings.
>>

Becuase you didnt use Order by clause

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -