Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    New York

    need help with mysql join statment

    I am trying to run a query with using a join and my issue is it is giving me an error saying their is not column named "MAX" so I am hoping someone can provide a better why to right this query

    PHP Code:
    SELECT teams.repteams.sup_manidMTD_AHT.Groupwiseidteams.MAXsup_manid ) , teams.Maxassign_date ), MTD_AHT.avg(AHT) AS AHT FROM teamsMTD_AHT WHERE teams.sup_manid 'jdoe' AND MONTH(assign_date) <='7' AND teams.rep MTD_AHT.Groupwiseid AND MTD_AHT.MTD=1 GROUP BY rep 
    what the query is suppose to do is provide an average of a AHT column for only people that are assigned to the person named jdoe for the month of july .

    I also tried writing this query this way which did not work
    PHP Code:
    //lets get the average for each column
    $gn2 mysql_query("SELECT rep, MAX( sup_manid ) , Max( assign_date ) FROM teams WHERE sup_manid = 'jdoe' AND MONTH(assign_date) <='7' GROUP BY rep");
    $nr2 mysql_fetch_array($gn2))
    //avg aht
    $getaht2 mysql_query("SELECT avg(AHT) AS AHT FROM MTD_AHT where GroupwiseID='$rep' AND MONTH(Date) ='7' AND MTD='1'");    
    $goalrow2 mysql_fetch_array($getaht2);    
    $ahtavg floor($goalrow2['AHT']);

    So basically I have a teams table that holds which people are assigned to which supervisor/manager then I have a table called MTD_AHT which stores a score for a specific performence measure. So what I need to do is for any given month get a which team members where assigned to a specific supervisor/manager and then get the total average score for the above quried performence measure
    just a programmer

  2. #2
    Join Date
    Dec 2007
    Your query has bad syntax from what it looks like.

    teams.MAX(sup_manid) should be MAX(teams.sub_manid)


Similar Threads

  1. help with mysql query statment
    By lordaya in forum Programming Discussion
    Replies: 2
    Last Post: 10-10-2007, 05:13 AM
    By raulgonzalez in forum Programming Discussion
    Replies: 1
    Last Post: 09-22-2007, 02:06 PM
  3. MySQL inner join error
    By jon31 in forum Programming Discussion
    Replies: 2
    Last Post: 04-14-2007, 05:24 PM
  4. Need some mySQL JOIN help
    By funkytaco in forum Web Design and Content
    Replies: 2
    Last Post: 01-03-2006, 10:58 AM
  5. mySQL join question
    By freakb0y in forum Programming Discussion
    Replies: 1
    Last Post: 05-11-2004, 01:44 PM

Posting Permissions

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