MySQL guery help needed

Discussion in 'PHP' started by KingCobra, Feb 10, 2010.

  1. #1
    [​IMG]

    Explain:
    D2 2 1 0
    (here D2 means a country, total positive value = 2, total negative value=1, tital unchanged vale = 0)

    What will be the query?
    PLEASE HELP
     
    KingCobra, Feb 10, 2010 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    
    SELECT country,
    SUM(IF(temp>0,1,0)) AS positive,
    SUM(IF(temp<0,1,0)) AS negative,
    SUM(IF(temp=0,1,0)) AS unchanged
    FROM weather
    GROUP BY country
    ORDER BY country ASC;
    
    Code (markup):
    ;)
     
    koko5, Feb 10, 2010 IP