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 |
gerten
Starting Member
17 Posts |
Posted - 2005-10-18 : 17:37:40
|
One statistic questiong from an db Resultat. SELECT m.Namn + ' ' + m.ENamn AS Spelare, SUM(r.Serier) AS Ser, SUM(r.Poang) AS Po, ROUND(SUM(r.Resultat) / SUM(r.Serier * 1.0), 2, 1)AS Snitt, ROUND(SUM(r.Poang * 1.0) / SUM(r.Serier), 2) AS [P Snitt], ROUND(SUM(r.Miss * 1.0 / r.Serier), 2, 1) AS Miss, SUM(r.Miss) AS [Sa Miss], MAX(r.Resultat) AS Bästa, MIN(r.Resultat) AS SämstaFROM Resultat r INNER JOINMedlemmar m ON r.Spelare = m.IDWHERE (r.Omgang IN (SELECT DISTINCT TOP 3 Omgang FROM Resultat ORDER BY Omgang DESC))GROUP BY m.Namn + ' ' + m.ENamnORDER BY 4 DESCWhat i want to do is sort out Min(r.Resultat) where serier is mor than 3, Not WHERE (r.Resultat) >3. More like in Access "Min(IIf(r.serier=4,r.resultat,Null)) AS [Sämsta]" But that i cant do in SQLHave also tryed with "WHERE (SELECT MIN(r.Serier) FROM Resultat Resultat r INNER JOIN medlemmar m ON r.Spelare = m.ID"Get lowest result same on all players.Best regGerten |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-19 : 02:29:25
|
Min(IIf(r.serier=4,r.resultat,Null)) AS [Sämsta] can be replaced in SQL Server byMin(Case When r.serier=4 then r.resultat else Null end) AS [Sämsta]This is the Forum to contribute workable scriptsHereafter post your questions at Relevent forums like Developer or Transact_SQLMadhivananFailing to plan is Planning to fail |
|
|
gerten
Starting Member
17 Posts |
Posted - 2005-10-19 : 10:45:36
|
Thank you for your help. Works just perfectI'll try to put my q in right forum hereby...Best regGerten |
|
|
|
|
|
|
|