Help with SQL query

Results 1 to 2 of 2

Thread: Help with SQL query

  1. #1
    Join Date
    Dec 1969

    Default Help with SQL query

    Hi,<BR><BR>I was wondering if anyone can help.<BR><BR>I am creating a database driven golf web site. This site allows people to enter their score for each game. <BR><BR>People enter the number of times it took them for each hole they played. In many case players will only play 9 instead of 18 holes. Therefore they will leave the score for holes 10-18 blank or enter "0".<BR><BR>What I want to do is count the score for each hole they played and have entered scores for. <BR><BR>I have a simple MS SQL database table for keeping the score<BR><BR>s_id (unique ID e.g 1)<BR>holenumberid (numeric e.g. 101 - links to a course table)<BR>holescore (numeric e.g 1)<BR>playerid (numeric e.g 1 - linsk to a players table)<BR><BR>Any ideas how I could count the score for the holes the user has played and has entered scores for in SQL <BR><BR><BR>Also I need to display the score for all holes played. <BR>What would be the best way to show on the page only the holes the player played and has entered scrores for. As explain the number of holes could vary - 9,18 or less<BR><BR>Many thanks<BR><BR>Mark

  2. #2
    Join Date
    Dec 1969

    Default RE: Help with SQL query

    Counting is easy:<BR><BR>SELECT COUNT(holescore)<BR>FROM MyTable<BR><BR>But if you want to count only the holes of a certain golfcourse, you should have another table linking the individual holes to a golfcourse, and join that table in your query as well.<BR><BR>As for only counting holes with scores &#062; 0, why bother. If a score is 0, then it won&#039;t add anything to the total score.<BR><BR>To display the score for the holes they placed you could add a where-clause to your query: "WHERE holescore &#062; 0"...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts