www.webdeveloper.com
Results 1 to 2 of 2

Thread: Building Select statement...

  1. #1
    Join Date
    Sep 2008
    Posts
    10

    Building Select statement...

    I'm trying to create a select statement that takes the max of the ot.possession column and divides it by 2 and puts that value in the football_schedule table as the column quarter...Right now when i run the query there is no output, any ideas?

    Code:
    SELECT *
    FROM customer_data.cd_football_game_scoring t, customer_data.cd_football_schedule s 
    WHERE s.quarter =(select(max(count(t.ot_possession) /2)) from customer_data.cd_football_game_scoring t group by t.game_code)
    AND t.game_code = 814533
    AND s.game_code = 814533
    AND t.scored = 'Y'

  2. #2
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    1,046
    Does you sub query return more than one value?

    Code:
    SELECT(MAX(COUNT(t2.ot_possession) /2)) 
    FROM customer_data.cd_football_game_scoring AS t2 
    GROUP BY t2.game_code
    Might need a WHERE condition in here as well

    Code:
    SELECT *
    FROM customer_data.cd_football_game_scoring AS t, customer_data.cd_football_schedule AS s
    WHERE s.quarter =(
         SELECT(MAX(COUNT(t2.ot_possession) /2)) 
         FROM customer_data.cd_football_game_scoring AS t2 
         WHERE t2.game_code = 814533  /* <-- Just a Guess */
         GROUP BY t2.game_code) /* <-- The group by will return multi rows without a where clause */
    AND t.game_code = 814533
    AND s.game_code = 814533
    AND t.scored = 'Y'

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles