Re: tutorial incorrect calculation want to understand
This is the wacky soluation I created:
mysql> select w.*, w.SALARY/w.WINS as CPW from (
-> SELECT s.yearID, s.teamID,
-> SUM(s.salary) AS SALARY,
-> t.W AS WINS
-> FROM Salaries s, teams t
-> WHERE s.yearID = 2002 AND s.teamID = t.teamID
-> AND s.yearID = t.yearID
-> GROUP BY s.teamID
-> ORDER BY SALARY DESC
-> ) as w;
+--------+--------+-----------+------+--------------------+
| yearID | teamID | SALARY | WINS | CPW |
+--------+--------+-----------+------+--------------------+
| 2002 | NYA | 125928583 | 103 | 1222607.6019417476 |
| 2002 | BOS | 108366060 | 93 | 1165226.4516129033 |
| 2002 | TEX | 105526122 | 72 | 1465640.5833333333 |
| 2002 | ARI | 102819999 | 98 | 1049183.663265306 |
| 2002 | LAN | 94850953 | 92 | 1030988.6195652174 |
| 2002 | NYN | 94633593 | 75 | 1261781.24 |
| 2002 | ATL | 92870367 | 101 | 919508.5841584158 |
| 2002 | SEA | 80282668 | 93 | 863254.4946236559 |
| 2002 | CLE | 78909449 | 74 | 1066343.9054054054 |
| 2002 | SFN | 78299835 | 95 | 824208.7894736842 |
| 2002 | TOR | 76864333 | 78 | 985440.1666666666 |
| 2002 | CHN | 75690833 | 67 | 1129713.9253731344 |
| 2002 | SLN | 74660875 | 97 | 769699.7422680412 |
| 2002 | HOU | 63448417 | 84 | 755338.2976190476 |
| 2002 | ANA | 61721667 | 99 | 623451.1818181818 |
| 2002 | BAL | 60493487 | 67 | 902887.8656716418 |
| 2002 | PHI | 57954999 | 80 | 724437.4875 |
| 2002 | CHA | 57052833 | 81 | 704355.9629629629 |
| 2002 | COL | 56851043 | 73 | 778781.4109589041 |
| 2002 | DET | 55048000 | 55 | 1000872.7272727273 |
| 2002 | MIL | 50287833 | 56 | 897997.0178571428 |
| 2002 | KCA | 47257000 | 62 | 762209.6774193548 |
| 2002 | CIN | 45050390 | 78 | 577569.1025641026 |
| 2002 | PIT | 42323599 | 72 | 587827.7638888889 |
| 2002 | FLO | 41979917 | 79 | 531391.3544303797 |
| 2002 | SDN | 41425000 | 66 | 627651.5151515151 |
| 2002 | MIN | 40425000 | 94 | 430053.1914893617 |
| 2002 | OAK | 40004167 | 103 | 388389.9708737864 |
| 2002 | MON | 38670500 | 83 | 465909.6385542169 |
| 2002 | TBA | 34380000 | 55 | 625090.9090909091 |
+--------+--------+-----------+------+--------------------+
30 rows in set (0.00 sec)
Subject
Written By
Posted
Re: tutorial incorrect calculation want to understand
January 27, 2015 08:52PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.