Loading ...
Sorry, an error occurred while loading the content.

Sum up values..

Expand Messages
  • Scott Barrett
    I am still pretty green at this SQL stuff, so I will try to explain this as best as I can. I have a table of stats, for a bunch of teams. I need to be able to
    Message 1 of 2 , Aug 5, 2004
    • 0 Attachment
      I am still pretty green at this SQL stuff, so I will try to explain
      this as best as I can.

      I have a table of stats, for a bunch of teams. I need to be able to
      Sum up the teams points, wins, losses and ties for the season.

      I have a table structure that looks like this:

      DI.AutoDivisionID -> DITMap.DivisionInfoID AND DITMap.TeamInfoID ->
      TI.AutoTeamID AND TI.AutoTeamID -> TSMap.TeamInfoID AND
      TSMap.TeamStatsID -> TS.AutoTeamStatsID..

      I hope this makes sense..?

      I have the following SELECT:

      SELECT * FROM DivisionInfo AS DI, DivisionInfoTeamMap AS DITMap,
      TeamInfo AS TI, TeamStatsMap AS TSPMap, TeamStats AS TS WHERE
      DI.AutoDivisionID=30 And DI.AutoDivisionID=DITMap.DivisionInfoID And
      DITMap.TeamInfoID=TI.AutoTeamID;

      With this, I get all the records for all the teams in the selected
      division. (DI.AutoDivisionID=30) So if I have 3 weeks of stats in the
      table, I get all the records, for all the teams, for all 3 weeks.
      What I want to be able to do, is Sum up all the points, wins, losses
      and ties for each of the teams, for the 3 weeks and ORDER BY Points
      DESC.. I am sure I am going to need to use SELECT Sum(Points)...
      FROM ... WHERE ... IN ( SELECT .... FROM ... WHERE .....) but I am
      not really sure how to do this..?

      Thanks in advance...!
      -Scott
    • Damhuis Anton
      Hi Scott. Sorry I don t have a lot of time to understand you names and Database structure in depth. If no-one else helps please post the following and I will
      Message 2 of 2 , Aug 6, 2004
      • 0 Attachment
        Hi Scott.

        Sorry I don't have a lot of time to understand you names and Database structure in depth.

        If no-one else helps please post the following and I will gladly have a look at it.

        Post a small sample of some data (simplified) and then also what you want to get out.

        Example:
        Create Table #TempPOC( ID int , value varchar(20))

        Insert into #TempPOC ( 1 , "Anton" )
        Insert into #TempPOC ( 1 , "AntonB" )
        Insert into #TempPOC ( 1 , "AntonC" )

        Drop Table #TempPOC

        Question:
        How do I extract only the 1st instance of "Anton"
        ~~end example~~

        This will allow me to much quicker understand what you want, and give me a base to work from (as I just past it into QA (assuming its MS based) )

        Maybe wait another day or so, and then do it. There might be someone in another time zone that will answer it shortly.

        Regards
        Anton


        -----Original Message-----
        From: Scott Barrett [mailto:scottsbmw@...]
        Sent: 06 August 2004 07:06
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: [SQLQueriesNoCode] Sum up values..

        Confidentiality Warning
        =======================

        The contents of this e-mail and any accompanying documentation
        are confidential and any use thereof, in what ever form, by anyone
        other than the addressee is strictly prohibited.
      Your message has been successfully submitted and would be delivered to recipients shortly.