我想将以下查询的输出存储在一个表中,但我无法存储,当我创建临时表以存储输出时,它给了我这种访问被拒绝的权限,请您帮我一下很棒。
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 ;
答案 0 :(得分:0)
我认为应该是这样
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 ;