Jump to content


Photo

How to AutoSum or add rows together


  • Please log in to reply
1 reply to this topic

#1 Leburn

Leburn
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 21 June 2006 - 11:23 AM

Hey guys,

I currently run a hockey related site using a combo of postnuke (for the news articles) and customized pages (made with MX)

I have come across a problem recently. My goal is to add up the Player's stats from each season into a career total.

Example:
Year    GP   G    A   Pts
1       10   8    2    10
2       10   2   10    12
3       10   4    2     6
Total   30  14   14    28 <---

In my database, I have the year-by-year stats for each player in one table

like

id1-Jaromir Jagr-1-10-8-2-10
id2-Jaromir Jagr-2-10-2-10-12
id3-Jaromir Jagr-3-10-4-2-6
and so on...

Hopefully someone can help me out.

Also, another little question.

How would I get DreamWeaver to display something if a record doesn't exist

Like say, Player A played the Season, but missed the playoffs. For the playoff stats I want DW to display GP-0, G-1, etc. if a record doesn't exist. As of right now, if a record doesn't exist, the tables are blank.

Thanks in advance.

#2 Leburn

Leburn
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 21 June 2006 - 06:09 PM

nevermind, I figured it out by searching for SUM

for those interested the code I used was

SELECT SUM(GP) AS GP, SUM(G) AS G, SUM(A) AS A, SUM(P) AS P, SUM(plusminus) AS plusminus, SUM(PIM) AS PIM, SUM(PP) AS PP, SUM(SH) AS SH, SUM(GW) AS GW, SUM(GT) AS GT, SUM(HT) AS HT, SUM(S) AS S, ROUND(AVG(PCTG), 1) AS PCTG
FROM stats_season
WHERE playername = 'colname'





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users