• per month sale single user query in mysql?

    Answered

    per month sale single user query in mysql?

    Bronze Member Asked on November 16, 2016 in MS SQL.
    Add Comment
  • 1 Answer(s)
    Best answer
    
    $query = mysql_query("SELECT user_id, sum(if(month(create_time) = 1, total_clicks, 0)) AS Jan,
    
    sum(if(month(create_time) = 2, total_clicks, 0)) AS Feb,
    
    sum(if(month(create_time) = 3, total_clicks, 0)) AS Mar,
    
    sum(if(month(create_time) = 4, total_clicks, 0)) AS Apr,
    
    sum(if(month(create_time) = 5, total_clicks, 0)) AS May,
    
    sum(if(month(create_time) = 6, total_clicks, 0)) AS Jun,
    
    sum(if(month(create_time) = 7, total_clicks, 0)) AS Jul,
    
    sum(if(month(create_time) = 8, total_clicks, 0)) AS Aug,
    
    sum(if(month(create_time) = 9, total_clicks, 0)) AS Sep,
    
    sum(if(month(create_time) = 10, total_clicks, 0)) AS Oct,
    
    sum(if(month(create_time) = 11, total_clicks, 0)) AS Nov,
    
    sum(if(month(create_time) = 12, total_clicks, 0)) AS `Dec`
    
    FROM un_sort_url WHERE user_id= ".$_GET['id']."
    
    GROUP BY user_id");
    
    $row_result = @mysql_fetch_array($query);
    
    
    Bronze Member Answered on November 16, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.