Как сохранить вывод хранимой процедуры в таблице - PullRequest
0 голосов
/ 05 декабря 2018

Я хочу сохранить вывод запроса ниже в таблице, но я не могу сохранить, и когда я создаю временную таблицу для хранения вывода, он дает мне такой доступ запрещен. Пожалуйста, если вы можете мне помочь, это будет оченьотлично полный.

        DELIMITER //
CREATE PROCEDURE air1(p_lname VARCHAR(50))
    BEGIN
    select
       ( SELECT @airtel:=testValue FROM airtel WHERE rank = (select round(count(rank)*p_lname) from airtel)) as airtel,
        (SELECT @idea:=testValue  FROM idea WHERE rank = (select round(count(rank)*p_lname) from idea)) as idea,
        (SELECT @jio:=testValue  FROM jio WHERE rank = (select round(count(rank)*p_lname) from jio)) as jio,
        (SELECT @voda:=testValue FROM voda WHERE rank = (select round(count(rank)*p_lname) from voda))  as voda,
        (select @airtel1:=count(operator_id)  from airtel where testValue < @airtel)as airtelpercentcount,
        (select @idea1:=count(operator_id)  from idea where testValue < @idea)as ideapercentcount,
        (select @jio1:=count(operator_id)  from jio where testValue < @jio)as jiopercentcount,
        (select @voda1:=count(operator_id)  from voda where testValue < @voda)as vodapercentcount,
        (select @airtel2:=count(operator_id) from airtel) as airtelcount,
        (select @idea2:=count(operator_id) from idea) as ideacount,
        (select @jio2:=count(operator_id) from jio) as jiocount,
        (select @voda2:=count(operator_id) from voda) as vodacount,
        (select ((@airtel1/@airtel2)*100))as airtelpercentage,
        (select ((@idea1/@idea2)*100))as ideapercentage,
        (select ((@jio1/@jio2)*100))as jiopercentage,
        (select ((@voda1/@voda2)*100))as vodapercentage;
        insert into julyoutput(airtel,idea,jio,voda,airtelpercentcount,ideapercentcount,jiopercentcount,vodapercentcount,airtelcount,ideacount,jiocount,vodacount,airtelpercent,ideapercent,jiopercent,vodapercent)
        select airtel,idea,jio,voda,airtelpercentcount,ideapercentcount,jiopercentcount,vodapercentcount,airtelcount,ideacount,jiocount,vodacount,airtelpercent,ideapercent,jiopercent,vodapercent from julyoutput ;
    END //
    DELIMITER ;

1 Ответ

0 голосов
/ 05 декабря 2018

Я думаю, что это должно быть что-то вроде

DELIMITER //
CREATE PROCEDURE air1(p_lname VARCHAR(50))
    BEGIN
    select
       ( SELECT @airtel:=testValue FROM airtel WHERE rank = (select round(count(rank)*p_lname) from airtel)) as airtel,
        (SELECT @idea:=testValue  FROM idea WHERE rank = (select round(count(rank)*p_lname) from idea)) as idea,
        (SELECT @jio:=testValue  FROM jio WHERE rank = (select round(count(rank)*p_lname) from jio)) as jio,
        (SELECT @voda:=testValue FROM voda WHERE rank = (select round(count(rank)*p_lname) from voda))  as voda,
        (select @airtel1:=count(operator_id)  from airtel where testValue < @airtel)as airtelpercentcount,
        (select @idea1:=count(operator_id)  from idea where testValue < @idea)as ideapercentcount,
        (select @jio1:=count(operator_id)  from jio where testValue < @jio)as jiopercentcount,
        (select @voda1:=count(operator_id)  from voda where testValue < @voda)as vodapercentcount,
        (select @airtel2:=count(operator_id) from airtel) as airtelcount,
        (select @idea2:=count(operator_id) from idea) as ideacount,
        (select @jio2:=count(operator_id) from jio) as jiocount,
        (select @voda2:=count(operator_id) from voda) as vodacount,
        (select @airtelpercentage:=((@airtel1/@airtel2)*100))as airtelpercentage,
        (select @ideapercentage:=((@idea1/@idea2)*100))as ideapercentage,
        (select @jiopercentage:=((@jio1/@jio2)*100))as jiopercentage,
        (select @vodapercentage:=((@voda1/@voda2)*100))as vodapercentage;
        insert into julyoutput(airtel,idea,jio,voda,airtelpercentcount,ideapercentcount,jiopercentcount,vodapercentcount,airtelcount,ideacount,jiocount,vodacount,airtelpercent,ideapercent,jiopercent,vodapercent)
        select @airtel,@idea,@jio,@voda,@airtel1,@idea1,@jio1,@voda1,@airtel2,@idea2,@jio2,@voda2:,@airtelpercentage,@ideapercentagedeapercent,@jiopercentage,@vodapercentage  ;
    END //
    DELIMITER ;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...