Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the nonâ€‘production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.
SELECT *
FROM mfugi_kpi_perioddata period1
WHERE period1.periodnumber = ( SELECT MAX(id) FROM mfugi_kpi_period )
OR period1.periodnumber = ( SELECT MAX(id) FROM mfugi_kpi_period WHERE id < ( SELECT MAX(id) FROM mfugi_kpi_period ) )
ORDER BY period1.periodnumber DESC, weeknumber ASC
SELECT sum(t.p1w1), sum(t.p1w2), sum(t.p1w3), sum(t.p1w4), sum(t.p2w1), sum(t.p2w2), sum(t.p2w3), sum(t.p2w4) FROM
(SELECT if(period_number=$period1 and weeknumber=1, kpi01value,0) as p1w1,
if(period_number=$period1 and weeknumber=2, kpi01value,0) as p1w2,
if(period_number=$period1 and weeknumber=3, kpi01value,0) as p1w3,
if(period_number=$period1 and weeknumber=4, kpi01value,0) as p1w4,
if(period_number=$period2 and weeknumber=1, kpi01value,0) as p1w1,
if(period_number=$period2 and weeknumber=2, kpi01value,0) as p1w2,
if(period_number=$period2 and weeknumber=3, kpi01value,0) as p1w3,
if(period_number=$period2 and weeknumber=4, kpi01value,0) as p1w4
FROM mfugi_kpi_perioddata period1
WHERE period1.periodnumber = $period1
OR period1.periodnumber = $period2) t;
SELECT t.kpi_number, sum(t.p1w1), sum(t.p1w2), sum(t.p1w3), sum(t.p1w4), sum(t.p2w1), sum(t.p2w2), sum(t.p2w3), sum(t.p2w4) FROM
(SELECT kpi_number, if(period_number=$period1 and weeknumber=1, kpi_value,0) as p1w1,
if(period_number=$period1 and weeknumber=2, kpi_value,0) as p1w2,
if(period_number=$period1 and weeknumber=3, kpi_value,0) as p1w3,
if(period_number=$period1 and weeknumber=4, kpi_value,0) as p1w4,
if(period_number=$period2 and weeknumber=1, kpi_value,0) as p1w1,
if(period_number=$period2 and weeknumber=2, kpi_value,0) as p1w2,
if(period_number=$period2 and weeknumber=3, kpi_value,0) as p1w3,
if(period_number=$period2 and weeknumber=4, kpi_value,0) as p1w4
FROM mfugi_kpi_perioddata period1
WHERE period1.periodnumber = $period1
OR period1.periodnumber = $period2
) t
group by t.kpi_number order by t.kpi_number;