Changes between Version 3 and Version 4 of Internal/cProcedures/aGeneratingReports


Ignore:
Timestamp:
Apr 7, 2016, 12:43:10 PM (9 years ago)
Author:
Olivera Tosic
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Internal/cProcedures/aGeneratingReports

    v3 v4  
    1212
    1313}}}
     14
     15To get total user reservations in minutes for certain period per machine:
     16
     17{{{
     18SELECT machines.name resource_name,
     19sum((reservations.end_date   + (reservations.endTime * 60))-(reservations.start_date + (reservations.startTime * 60)))/60 duration
     20FROM reservations
     21LEFT JOIN reservation_users ON reservation_users.resid = reservations.resid
     22LEFT JOIN machines         ON reservations.machid = machines.machid
     23WHERE unix_timestamp('2000-01-01') <=(reservations.start_date + (reservations.startTime * 60))  AND
     24unix_timestamp('2016-03-31') >= (reservations.end_date   + (reservations.endTime * 60))
     25AND is_pending = 0
     26GROUP BY resource_name
     27ORDER BY duration desc
     28}}}
     29
     30To get total resource reservations in minutes for certain period per machine.
     31This is slightly different than above because user can invite other user(s) to his reservation.
     32{{{
     33SELECT machines.name resource_name,
     34sum((reservations.end_date   + (reservations.endTime * 60))-(reservations.start_date + (reservations.startTime * 60)))/60 duration
     35FROM reservations
     36LEFT JOIN machines         ON reservations.machid = machines.machid
     37WHERE unix_timestamp('2016-03-01') <=(reservations.start_date + (reservations.startTime * 60))  AND
     38unix_timestamp('2016-03-31') >= (reservations.end_date   + (reservations.endTime * 60))
     39AND is_pending = 0
     40GROUP BY resource_name
     41ORDER BY resource_name;
     42}}}
     43