如何在过程中在mysql中划分两个结果集

时间:2018-12-20 04:11:19

标签: mysql

我已经制定了一个程序,该程序给了我1)beta和2)r_squared两列的中位数。现在我想将beta除以r_squared的平方根。那我该怎么办呢?

CREATE DEFINER=`root`@`localhost` PROCEDURE `Sector_Averages`(IN Industry varchar(500))
BEGIN

drop temporary table if exists tmp;
create temporary table tmp(beta varchar(50), r_squared varchar(50));

SET @rowindex := -1;

SELECT
   AVG(g.beta),
   AVG(g.r_squared)
FROM 
   (SELECT @rowindex:=@rowindex + 1 AS rowindex,
           beta_analysis.beta AS beta,
            beta_analysis.r_squared AS r_squared

    FROM investometrics.beta_analysis where _1 in (select _1 from company_details  where _90002 = Industry)
    ORDER BY beta asc,r_squared asc) AS g
WHERE 
g.rowindex IN (FLOOR(@rowindex / 2) , CEIL(@rowindex / 2));


END

CREATE DEFINER=`root`@`localhost` PROCEDURE `Sector_Averages`(IN Industry varchar(500))
BEGIN

drop temporary table if exists tmp;
create temporary table tmp(beta varchar(50), r_squared varchar(50));

SET @rowindex := -1;

SELECT
   AVG(g.beta),
   AVG(g.r_squared)
FROM 
   (SELECT @rowindex:=@rowindex + 1 AS rowindex,
           beta_analysis.beta AS beta,
            beta_analysis.r_squared AS r_squared

    FROM investometrics.beta_analysis where _1 in (select _1 from company_details  where _90002 = Industry)
    ORDER BY beta asc,r_squared asc) AS g
WHERE 
g.rowindex IN (FLOOR(@rowindex / 2) , CEIL(@rowindex / 2));

END

我想回答:= beta/sqroot(r_Squared) 这就是总的beta(股票)

0 个答案:

没有答案