ALTER VIEW tests_view (
 id,
 theme_id,
 experience_id,
 checking_user_id,
 date_end,
 date_evaluation,
 test_status,
 avg_test,
 author_id,
 user_id,
 first_name,
 gender,
 birth_date,
 birth_country_id,
 city,
 edu_level_id,
 specialization_id,
 price_per_hour_id,
 cv,
 payment_method,
 user_status
) as
SELECT  t1.id,
		    t1.theme_id,
        t2.experience_id,
        t1.checking_user_id,
        t1.date_end,
        t1.date_evaluation,
        t1.status as 'test_status',
        case when t1.status is not null THEN (
          ifnull(t1.sum_style, 0) +
        	ifnull(t1.sum_grammar, 0) +
        	ifnull(t1.sum_briefing, 0) +
        	ifnull(t1.sum_information, 0) +
        	ifnull(t1.sum_interest, 0) +
        	ifnull(t1.sum_tone, 0)
        ) / (
          (t1.sum_style IS NOT NULL) +
        	(t1.sum_grammar IS NOT NULL) +
        	(t1.sum_briefing IS NOT NULL) +
        	(t1.sum_information IS NOT NULL) +
        	(t1.sum_interest IS NOT NULL) +
        	(t1.sum_tone IS NOT NULL)
        ) ELSE null END as 'avg_test',
        t3.id as 'author_id',
        t3.user_id,
        CONCAT(t3.first_name, ' ', t3.last_name) as 'first_last_name',
        t3.gender,
        t3.birth_date,
        t3.birth_country_id,
        t3.city,
        t3.edu_level_id,
        t3.specialization_id,
        t3.price_per_hour_id,
        t3.cv,
        t3.payment_method,
        t4.status as 'user_status'

  FROM 	`tests` as t1
  LEFT JOIN `themes` as t2 on t2.id = t1.theme_id

  JOIN `authors` as t3 on t1.author_id = t3.id
  JOIN `user`     as t4 on t4.id = t3.user_id