Using queries

Queries are customized searches of core databases. This product provides tools that let you create database queries for devices in your core database, as well as a method for you to create LDAP queries for devices located in other directories. You create core database queries in the console's Query view. You create LDAP queries with the Directory manager tool.

Read this section to learn about:

Queries overview

Queries help you manage your network by allowing you to search for and organize devices in the core database based on specific system or user criteria.

For example, you can create and run a query that captures only devices with a processor clock speed of less than 2 GHz, or with less than 1 GB of RAM, or with a hard drive of less than 80 GB. Create one or more query statements that represent those conditions and relate statements to each other using standard logical operators. When the queries are run, you can print the results of the query, and access and manage the matching devices.

Creating database queries

Use the New query dialog to build a query by selecting from attributes, relational operators, and attribute values. Build a query statement by choosing an inventory attribute and relating it to an acceptable value. Logically relate the query statements to each other to ensure they're evaluated as a group before relating them to other statements or groups.

To create a database query
  1. In the left navigation pane, click Reporting > Queries, then click New on the toolbar.
  2. Select a component from the inventory attributes list.
  3. Under Step 1: Search conditions, click Edit.
    1. Drill down this list to select the attributes that will be your search condition. For example, to locate all clients running a particular type of software, you would select Computer.Software.Package.Name.
    2. After selecting the attributes, you'll notice that a series of fields appear in the right side of the window. From these fields, select an operator and value to complete the search condition. For example, to locate all clients running Internet Explorer 6.0, the attributes would be "Computer.Software.Package.Name," the operator "=," and the value "Internet Explorer 6."
    3. At the bottom of the window, click Add to fill in the empty field with your search condition.
    4. You can continue to refine the query by creating another search condition, then adding it to the first with a boolean operator (AND or OR) . Also use the buttons to add, delete, replace, group, or ungroup the conditions you create.
    5. When you're finished, click OK.
  4. Under Step 2: Attributes to display, click Edit.
    1. Drill down this list to select an attribute to display in the query results list. Remember to select attributes that will help you identify the clients returned in the query.

      NOTE: If you're using an Oracle database, make sure you select at least one attribute that is natively defined by the inventory scanner (for example, Computer.Display Name, Computer.Device Name, Computer.Device ID, Computer.Login Name, and so on).

    2. After you've selected an attribute, click Add to move it into the empty field on the bottom of the window. If you want to enumerate your query results list, click Include count.
    3. Repeat the process if you want to add more attributes. Use the Remove button to remove attributes, and click Move up or Move down to change the order of attributes.
    4. Click Make results targetable to enable the results of the query to be targetable for any actions you specify.
    5. When you're finished, click OK.
  5. (optional) Under Step 3: Sort results by attribute, click Edit to customize the order of query results.
  6. If you want to run the query additional times, click Save query, and enter a unique name for the query. If you run the query prior to saving it, the query parameters are lost and must be reconstructed to run the same query again.
  7. Under Step 4: Run query, click Run query.

Query statements are executed in the order shown
If no groupings are made, the query statements listed in this dialog are executed in order from the bottom up. Be sure to group related query items so they're evaluated as a group; otherwise, the results of your query may be different than you expect.

Running queries

To run a query
  1. In the left navigation pane, click Reporting > Queries.

  2. Select the query and click Run. If you want to make changes to the query before running it, click the query, click Edit, modify steps 1-3, and then click Run query.

    NOTE: Note: If you have modified the query and want to save your changes, click Save query to save the changes or Save query as to give the modified query a new name. Do this before running the query. If you do not save your changes before running the query, the changes will not be saved with the query.

  3. The results (matching devices) display in the right-hand pane of the All devices view.
  4. To save the results as a comma-separated value file, click the Save as CSV button on the toolbar. To print the results, click the Print view button.