Markkinadata

[insert_php]
$con = mysql_connect("db1.kapsi.fi", "jarso", "6iATm5pmHw") or die ("Connection failed");

mysql_select_db("jarso", $con) or die ("Connection failed");

$last30 = "SELECT round(avg(erp),5) FROM (select erp from impliederp ORDER BY Id DESC LIMIT 30) avgs";
$latest = "SELECT erp FROM impliederp ORDER BY Id DESC LIMIT 1";
$latestdate = "SELECT date FROM impliederp ORDER BY Id DESC LIMIT 1";
$haku = mysql_query($latest,$con) or die ("Error");
$haku2 = mysql_query($last30,$con) or die ("Error");
$haku3 = mysql_query($latestdate,$con) or die ("Error");
$max = mysql_query("SELECT max(erp) FROM impliederp",$con) or die ("Error");
$min = mysql_query("SELECT min(erp) FROM impliederp",$con) or die ("Error");
$averageall = mysql_query("SELECT round(avg(erp),5) FROM impliederp",$con) or die ("Error");
$average = mysql_result($haku2, 0) * 100;
$latesterp = mysql_result($haku, 0) * 100;
$latesterpdate = mysql_result($haku3, 0);
$spmax = mysql_result($max, 0) * 100;
$spmin = mysql_result($min, 0) * 100;
$spaveragall = mysql_result($averageall, 0)*100;

$latestebitda = mysql_query("SELECT ebitda FROM ebitda ORDER BY Id DESC LIMIT 1",$con) or die ("Error");
$latestebitdadate = mysql_query("SELECT date FROM ebitda ORDER BY Id DESC LIMIT 1",$con) or die ("Error");
$sp500ebitda = mysql_result($latestebitda, 0);
$sp500ebitdadate = mysql_result($latestebitdadate, 0);

$last30omxh = "SELECT round(avg(erp),5) FROM (select erp from imperpomxh25 ORDER BY Id DESC LIMIT 30) avgs";
$latestomxh = "SELECT erp FROM imperpomxh25 ORDER BY Id DESC LIMIT 1";
$latestomxhdate = "SELECT date FROM imperpomxh25 ORDER BY Id DESC LIMIT 1";
$maxomxh = mysql_query("SELECT max(erp) FROM imperpomxh25",$con) or die ("Error");
$minomxh = mysql_query("SELECT min(erp) FROM imperpomxh25",$con) or die ("Error");
$averageallomxh = mysql_query("SELECT round(avg(erp),5) FROM imperpomxh25",$con) or die ("Error");
$hakuomxhlatest = mysql_query($latestomxh,$con) or die ("Error");
$hakuomxhlatest2 = mysql_query($latestomxhdate,$con) or die ("Error");
$hakuomxhlatest3 = mysql_query($last30omxh,$con) or die ("Error");
$latestomxherp = mysql_result($hakuomxhlatest, 0) * 100;
$averageomxherp = mysql_result($hakuomxhlatest3, 0) * 100;
$latestomxherpdate = mysql_result($hakuomxhlatest2, 0);
$omxhaverageall = mysql_result($averageallomxh, 0) * 100;
$omxhmax = mysql_result($maxomxh, 0) * 100;
$omxhmin = mysql_result($minomxh, 0) * 100;

$latestebitdahel = mysql_query("SELECT round(ebitda,2) FROM ebitdaomxh ORDER BY Id DESC LIMIT 1",$con) or die ("Error");
$latestebitdadatehel = mysql_query("SELECT date FROM ebitdaomxh ORDER BY Id DESC LIMIT 1",$con) or die ("Error");
$omxhebitda = mysql_result($latestebitdahel, 0);
$omxhebitdadate = mysql_result($latestebitdadatehel, 0);

echo "

";
echo "

";
echo "

";
echo "

";
echo "

";
echo "

";
echo "

";
echo "

";
//echo "

";
//echo "

";
echo "

";

//echo "

";
//echo "

";
//echo "

";
//echo "

";
//echo "

";
//echo "

";
//echo "

";
//echo "

";
//echo "

";

echo "

";
echo "

S&P 500
PVM Riskipreemio*
$latesterpdate $latesterp %
Keskiarvo $spaveragall %
30 pv keskiarvo $average %
Maksimi $spmax %
Minimi $spmin %
PVM EV/EBITDA
$sp500ebitdadate $sp500ebitda
OMXH 25
PVM Riskipreemio**
$latestomxherpdate $latestomxherp %
Keskiarvo $omxhaverageall %
30 pv keskiarvo $averageomxherp %
Maksimi $omxhmax %
Minimi $omxhmin %
PVM EV/EBITDA
$omxhebitdadate $omxhebitda
* 5.9.2014 alkaen

";
echo "

";

[/insert_php]