Documentation Center

  • Trial Software
  • Product Updates

Displaying Query Results

How to Display Query Results

To display query results, perform one of the following actions:

  • Enter the variable name to which to assign the query results in the MATLAB® Command Window.

  • Double-click the variable in the VQB Data area to view the data in the Variables editor.

The examples in this section use the saved query basic.qry. To load and configure this query:

  1. Select Query > Preferences, and set Read NULL numbers as to 0.

  2. Select Query > Load.

  3. In the Load SQL Statement dialog box, select basic.qry from the File name field and click Open.

  4. In VQB, enter a value for the MATLAB workspace variable, for example, A, and click Execute.

Displaying Data Relationally

To display the results of basic.qry:

  1. Execute basic.qry.

  2. Select Display > Data.

    The query results appear in a figure window.

    This display shows only unique values for each field, so you should not read each row as a single record. In this example, there are 10 entries for StockNumber, eight entries for January and February, and 10 entries for March. The number of entries in each field corresponds to the number of unique values in the field.

  3. Click a value in the figure window, for example, StockNumber 400876, to see its associated values.

    The data associated with the selected value appears in bold font and is connected with a dotted line. The data shows that sales for item 400876 are 3000 in January, 2400 in February, and 1500 in March.

  4. As another example, click 3000 under January. It shows three different items with sales of 3000 units in January: 400314, 400876, and 400999.

Charting Query Results

To chart the results of basic.qry:

  1. Select Display > Chart.

    The Visual Query Builder Charting dialog box appears.

  2. Select a type of chart from the Charts list. In this example, choose a pie chart by specifying pie.

    A preview of the pie chart, with each stock item displayed in a different color, appears at the bottom of the dialog box.

  3. Select the data to display in the chart from the X data, Y data, and Z data list boxes. In this example, select March from the X data list box to display a pie chart of March data.

    The pie chart preview now shows percentages for March data.

  4. To display a legend, which maps colors to the stock numbers, select the Show legend check box.

    The Legend labels field becomes active.

  5. Select StockNumber from the Legend labels list box.

    A legend appears in the chart preview. Drag and move the legend in the preview as needed.

  6. Click Close to close the Charting dialog box.

Displaying Query Results in an HTML Report

To display results for basic.qry in an HTML report, select Display > Report.

The query results appear as a table in a Web browser. Each row represents a record from the database. In this example, sales for item 400876 are 3000 in January, 2400 in February, and 1500 in March.

    Tip   Because some browsers do not start automatically, you may need to open your Web browser before displaying the query results.

Displaying Query Results with MATLAB Report Generator

To use the MATLAB Report Generator™ software to customize the display of the results of basic.qry:

  1. Select Display > Report Generator.

  2. The Report Explorer opens, listing sample report templates that you can use to create custom reports. Select the template matlabroot/toolbox/database/vqb/databasetlbx.rpt from the Options pane in the middle of the Report Explorer window.

  3. Open the report template for editing by clicking Open a Report file or stylesheet.

    1. In the Outline pane on the left, under Report Generator > databasetlbx.rpt, select Table.

    2. In the Properties pane on the right, do the following:

      1. In Table Content > Workspace Variable Name, enter the name of the variable to which you assigned the query results in VQB, for example, 'A'.

      2. Under Header/Footer Options, set Number of header rows to 0.

    3. Click Apply.

  4. Select File > Report to run the report.

    The report appears in a Web browser.

  5. Field names do not automatically display as column headers in the report. To display the field names:

    1. Modify the workspace variable A as follows:

      A = [{'Stock Number', 'January', 'February', 'March'};A]
      
    2. In the MATLAB Report Generator Properties pane, change Number of header rows to 1 and regenerate the report. The report now displays field names as headings.

      Each row represents a record from the database. For example, sales for item 400876 are 3000 in January, 2400 in February, and 1500 in March.

For details about the MATLAB Report Generator product, click the Help button in the Report Explorer.

    Tip   Because some browsers are not configured to launch automatically, you may need to open your Web browser before displaying the report.

Was this topic helpful?