Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A query can be created using the web interface if a user has a role that contains the queries::create permission. Go to menu: Manage -> Queries -> Create Queries. There is also a create button on the collection page.

Image Modified

 

 

 

 

 

 

 

 

 

 

Image Modified









View Query Details

...

You can also edit or delete any query.

Image Modified












Image Modified









Examples

Devices Older Than X

This example query retrieves a list of devices OVER 5 years old. The query uses today (NOW) and system.purchase_date as the reference point. You could do something similar with system.warranty_expires and look for a warranty expiration date within the next 90-days or already expired.

AS `system.manufacturer`, system.model AS `system.model`, system.description AS `system.description`, system.function AS `system.function`, locations.name AS `locations.name` FROM system LEFT JOIN locations ON (system.location_id = locations.id) LEFT JOIN windows ON (system.id = windows.system_id AND windows.current = 'y') LEFT JOIN orgs ON (system.org_id = orgs.id) WHERE @filter HAVING system.purchase_date < DATE_SUB(NOW(),INTERVAL 5 YEAR)

Database Schema

The schema for the database is below. It can also be found in the application if the user has database::read permission by going to menu: Manage -> Database -> List Database, then clicking on the "queries" table.

...