Three month power saving report now only shows current month
I ran the 3 month power saving report. Now only see July but not June and May. Any Ideas?
Answers (2)
I know this might be an obvious answer, but did you have the client installed in May and June?
This will give you all records created in the past month. Does this return anything?
select NAME, IP, USER, CREATED FROM MACHINE WHERE CREATED BETWEEN (ADDDATE(LAST_DAY(SUBDATE(NOW(), INTERVAL 2 MONTH)), INTERVAL 1 DAY)) AND LAST_DAY(SUBDATE(NOW(), INTERVAL 1 MONTH)) ORDER BY CREATED DESC
What changed a month ago? Did you upgrade or export? Did someone break the report on you?
Mine works
this is what is in the SQL box
SELECT NAME, MAC, CUR_MONTH, CUR_HOURS, PREV_MONTH_HOURS, PREV_MONTH2_HOURS,
(PREV_MONTH_HOURS-CUR_HOURS) AS CUR_HOURS_SAVED,
(PREV_MONTH_HOURS-CUR_HOURS)*150/1000 AS kWh_SAVED,
(PREV_MONTH_HOURS-CUR_HOURS)*150/1000*.15 AS SAVED,
(PREV_MONTH_HOURS-CUR_HOURS)/PREV_MONTH_HOURS*100 as CUR_PCT_SAVED,
(PREV_MONTH2_HOURS-PREV_MONTH_HOURS) as PREV_HOURS_SAVED,
(PREV_MONTH2_HOURS-PREV_MONTH_HOURS)*150/1000 as PREV_kWh_SAVED,
(PREV_MONTH2_HOURS-PREV_MONTH_HOURS)*150/1000*.15 as PREV_SAVED,
(PREV_MONTH2_HOURS-PREV_MONTH_HOURS)/PREV_MONTH2_HOURS*100 as PREV_PCT_SAVED
FROM (SELECT NAME, MAC, DATE_FORMAT(NOW(), '%Y-%m') AS CUR_MONTH,
(select AVG(HOURS)
from MACHINE_DAILY_UPTIME MDU
WHERE DAY > LAST_DAY(SUBDATE(NOW(), INTERVAL 1 MONTH))
AND M.ID = MDU.MACHINE_ID
) AS CUR_HOURS,
(select AVG(HOURS)
from MACHINE_DAILY_UPTIME MDU
WHERE DAY BETWEEN (ADDDATE(LAST_DAY(SUBDATE(NOW(), INTERVAL 2 MONTH)), INTERVAL 1 DAY)) AND LAST_DAY(SUBDATE(NOW(), INTERVAL 1 MONTH))
AND M.ID = MDU.MACHINE_ID
) AS PREV_MONTH_HOURS,
(select AVG(HOURS)
from MACHINE_DAILY_UPTIME MDU
WHERE DAY BETWEEN (ADDDATE(LAST_DAY(SUBDATE(NOW(), INTERVAL 3 MONTH)), INTERVAL 1 DAY)) AND LAST_DAY(SUBDATE(NOW(), INTERVAL 2 MONTH))
AND M.ID = MDU.MACHINE_ID
) AS PREV_MONTH2_HOURS
from MACHINE M
WHERE M.CHASSIS_TYPE = 'desktop') AS AVERAGES
ORDER BY NAME
Comments:
-
Wow Smal that's a big answer. Can you edit this and take the XML data out? It should not be his issue. The issue would be more in the query itself.
WJ if you can post the query that are using? Unless it matches the default one and hasn't been edited. - dugullett 12 years ago -
there you go. - SMal.tmcc 12 years ago