You are on page 1of 186

BI/Query

Queries Guide

8497-1M
8497-1M
Hummingbird Ltd.
1 Sparks Avenue, North York, Ontario, Canada M2H 2W1
Telephone (Canada and USA): +1-877-FLY HUMM (+1-877-359-4866)
Telephone (Worldwide): +1-416-496-2200
Fax: +1-416-773-5825
BBS: +1-416-496-9233
E-mail: getinfo@hummingbird.com
Web Site: www.hummingbird.com
FTP: ftp.hummingbird.com
RESTRICTED RIGHTS LEGEND. Unpublished rights reserved under the copyright laws of the United States. The SOFTWARE
is provided with restricted rights. Use, duplications, or disclosure by the U.S. Government is subject to restrictions as set forth in
subparagraph (c) (1) (ii) of The Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, subparagraph (c)(1)
and (2) (a) (15) of the Commercial Computer Software-Restricted Rights clause at 48 CFR 52.227-19, as applicable, similar clauses in
the FAR and NASA FAR Supplement, any successor or similar regulation.
Copyright © 2000 Hummingbird Ltd. All rights reserved. BI/Analyze, BI/Analyze CubeCreator, BI/Broker, BI/Broker Admin,
BI/Broker Repository, BI/Query, BI/Query Admin, BI/Query Reports, BI/Query Reports Chart Editor, BI/Query Update,
BI/Query User, BI/Suite, BI/Web, BI/Web Personal Portfolio, Genio Designer, Genio Engine, Genio Met@Data Explorer, Genio
Met@Data Studio, Genio MetaLink, Genio Repository, Genio Scheduler, and Genio Suite are trademarks of Hummingbird Ltd. and/or
its subsidiaries.
BI/Suite makes use of the Blowfish library, an SSL implementation written by Eric Young, © 1995–1997, Eric Young. All rights reserved.
Adobe, Acrobat, and Acrobat Reader are trademarks of Adobe Systems Incorporated.
DB2 is a trademark, and OS/2 is a registered trademark, of International Business Machines Corporation.
Hyperion Essbase OLAP Server is a trademark of Hyperion Solutions Corporation.
Ingres/Net is a trademark of Computer Associates International, Inc.
Java is a trademark of Sun Microsystems, Inc.
MetaCube is a registered trademark of Informix Software, Inc.
Microsoft, Microsoft Excel, Microsoft Word, Visual Basic, Windows, Windows 95, Windows 98, and Internet Explorer are registered
trademarks, and Windows NT is a trademark, of Microsoft Corporation.
NCR TeraCube and Teradata are registered trademarks, and WinCLI is a trademark, of NCR Corporation.
Netscape, Navigator, and Communicator are trademarks of Netscape Communications Corporation.
Oracle and SQL*Net are registered trademarks of Oracle Corporation.
Palm is a trademark of Palm, Inc. Quicksheet is a trademark of Cutting Edge Software, Inc.
Photo clipart copyright © 1996 PhotoDisc, Inc.
SequeLink is a trademark of Intersolv, Inc.
Sybase is a registered trademark of Sybase, Inc.
WhiteLight Server is a trademark of WhiteLight Systems, Inc.
All other copyrights, trademarks, and tradenames are the property of their respective owners.
DISCLAIMER. Hummingbird software and documentation has been tested and reviewed. Nevertheless, Hummingbird Ltd. makes no
warranty or representation, either express or implied, with respect to the software and documentation included. In no event will
Hummingbird Ltd. be liable for direct, indirect, special, incidental, or consequential damages resulting from any defect in the software or
documentation included with these products. In particular, Hummingbird Ltd. shall have no liability for any programs or data used with
these products, including the cost of recovering such programs or data.
Information in this document is subject to change without notice and does not represent a commitment on the part of Hummingbird
Ltd. Not all copyrights pertain to all products.
This guide contains proprietary information that is protected by copyright. All rights are reserved. This guide may not be photocopied,
reproduced, or translated into another language, in whole or in part, without prior written consent from Hummingbird.
This edition published October 2000. Available in PDF format only.
Printed in Canada.
Contents
Welcome to BI/Query 3 Starting BI/Query 21
About This Guide 3 Finding the Administrator Layer
in a Split Data Model 23
Conventions 3
Connecting 24
Illustrations 4
Related Documentation 4 Using a Default Connection File 25
Using Another Connection File 25
Guides 4
Entering Additional Information 26
Online Help 5
Technical Support 5 Disconnecting 26

Contacting Technical Support 6


Building Queries 29
Troubleshooting Using the Trace Utility 7 Selecting Attributes 30
Professional Services 7 Qualifying Queries 32
Contacting Professional Services 8 Using the Qualification Tree 32
The Business Intelligence Product Line 8 Using the Data Values Icon 35
Hummingbird Genio Suite 8 Reversing Qualifications 39
Hummingbird BI/Suite 9 Applying Multiple Qualifications 40
Contacting Hummingbird Sales 12 Combining Qualifications 41
Restricting Qualifications with Operators 42
Basic Concepts 15
Performing Calculations 47
Working with Data Models 15
Applying Functions to Attributes 47
Data Objects 15
Attributes 16 Creating Attributes That Perform
Calculations 55
Relationships 16
Ordering Query Results 58
Building Queries 17
Ordering Columns 58
Buttons 18
Sorting Rows 60
Turning Data into Reports 18
Submitting Queries 64

Getting Started 21 Saving Queries 64


Installing BI/Query 21 Loading Queries 66
Saving Results 67

Contents iii
Formatting Data 71 Creating Variables 108
Entering Data 71 Specifying Attributes and Operators 110
Default Format 71 Including Functions 113
Matching Display Formatting 71 Including Variables 114
Numbers 72 Including Prompts 115
Dates 73 Importing Variables from a File 116
Invalid Entries 73 Using Variables to Supply User Names 117
Converting Two-digit Years 73
Building Advanced Queries 121
Displaying Data 75
Qualifying One Attribute with
Formatting Numbers 76 Another 121
Formatting Dates 77 Qualifying an Attribute with a
Inserting and Deleting Characters 77 Subquery 122
Substituting Values 78 Modifying the SQL 125
Modifying a Query for Selected
Data Values Files, Prompts, and Results 126
Variables 83
Narrowing the Range of Results 128
Data Values Files 83
Combining Queries 129
Naming and Storing Data Values Files 85
Appending One Results Set to Another 130
Creating Data Values Results Files 86
Joining One Column to Another 132
Creating Data Values Query Files 90
Editing Combined Queries 136
Using Data Values Files to Alias Data 93
Using the Super Query window 137
Prompts 96
Editing a Component Query 138
Naming and Storing Prompts 97
Editing an Operation 139
Creating Single Prompts 97
Correcting Errors 140
Group Prompts 98
Creating Dynamic Relationships 142
Conditional Prompts 101
Building Queries with a Circular Path 144
Importing Prompts 106
With a Correlation 145
Variables 107
Without a Correlation 149

iv Contents
Exporting Information 155
Exporting Queries 155
Exporting Results 156
Copying and Pasting Results 157
Saving Results to a File 157
Exporting Results to an Application 158
Preparing Results for Export 159
Specifying Results Options 159
Setting Export Options 161
Exporting to Excel Using DDE 163
Common DDE Commands 163
Setting Export Options for Excel 164
Using Two Commands 164
Using the First Command only on Startup 165
Issuing Two Commands to Obtain
the Effect of Three 165
Combining Three Results Sets 166
Sending Current Results to Excel 167
Running a Macro That Calculates a
12-month Moving Total 168
Export Results Using Mail 169

Index 171

Contents v
Welcome to BI/Query

About This Guide 3


Conventions 3
Illustrations 4
Related Documentation 4
Guides 4
Online Help 5
Technical Support 5
Contacting Technical Support 6
Troubleshooting Using the Trace Utility 7
Professional Services 7
Contacting Professional Services 8
The Business Intelligence Product Line 8
Hummingbird Genio Suite 8
Hummingbird BI/Suite 9
Hummingbird BI/Broker 10
Hummingbird BI/Web 10
Hummingbird BI/Query 10
Hummingbird BI/Analyze 11
Contacting Hummingbird Sales 12
Welcome to BI/Query
Hummingbird BI/Query is a query and reporting tool that allows you to
access, analyze, and present data stored in enterprise databases. When it’s
installed with Hummingbird BI/Broker Repository, it also offers secure
scheduling and exchange of corporate data. Administrators use BI/Query
to create data models for querying. Business users query databases,
integrate data with other applications, and generate reports.

About This Guide


This guide describes how to use BI/Query to create and modify queries
in order to obtain information from corporate databases. It applies to
BI/Query Admin, BI/Query User, and BI/Query Update for Windows
95, Windows 98, and Windows NT.

Conventions
This guide uses certain conventions to help you use it effectively.

This Is Used for This

folder Directory, subdirectory, and folder.

italics New terms, file names, and information that you


type in the software.

Providing useful hints and suggestions.

Welcome to BI/Query 3
Illustrations
The illustrations in this guide are based on fictitious data. Some
illustrations may look somewhat different than what you see on your
monitor. Nevertheless, their functionality is the same.

Related Documentation
For information about installing and using BI/Query as well as using
other Hummingbird applications, see the documentation outlined
below. (For information about these applications, see “Hummingbird
BI/Suite” on page 9.)

Guides
The following guides describe the features, functionality, and
Electronic Documents
applications of Hummingbird’s BI/Suite software.
All guides are available
online as Adobe Acrobat
Portable Document For- Use This Guide To Do This
mat (PDF) files. If you
installed the documenta- BI/Query Determine system requirements and install
tion with the software, it’s Installation Guide BI/Query and BI/Query Reports.
accessible from the Start
menu. It’s also available on BI/Query Create and manage data models and update
the installation CD-ROM. Data Models Guide records in the database.
To open a PDF file, you BI/Query Produce reports using BI/Query Reports
need Acrobat Reader. It’s
Reports Guide from data obtained using BI/Query.
provided on the installation
CD-ROM and is also BI/Broker Configure and manage BI/Broker, and set
available at Adobe’s Web Administrator’s Guide up the security, publishing, and scheduling
site (http://www.adobe.com).
features it provides.
Using Acrobat 3.0 or later
allows you to take advan- BI/Broker Publish and secure data models, queries,
tage of its Find facility. Publishing and data sources, and reports in a common
Scheduling Guide repository using desktop applications. Also,
schedule queries, reports, and HyperCubes.

4 Welcome to BI/Query
Use This Guide To Do This

BI/Analyze Learn how to use BI/Analyze to discover


Tutorial trends, patterns, and relationships in data.

BI/Analyze Create and manage BI/Analyze multi-


CubeCreator Guide dimensional data sources.

BI/Web User’s Guide Learn how to use BI/Web to use data


models, queries, data sources, and reports in
your Web browser. (Available in PDF
format only. See “Electronic Documents”
on page 4.)

Online Help
Online help provides step-by-step instructions for using a product. You Tool tips allow
can access online help in a number of ways. you to find infor-
mation about
menu commands
To Do This Do This and toolbars. Position the
cursor over the item to dis-
Display contents Choose Help>Contents. play a brief description on the
status bar.
Locate specific information Choose Help>Search for Help On,
then specify what you’re looking for.

Get Help about using Help Choose Help>How to use Help.

Get Help for a dialog box Click the Help button in the dialog
box.

Technical Support
The administrator of this product in an organization should be the first
contact for technical support. (The administrator is most familiar with
the organization’s particular configuration.) If the problem isn’t
resolved, the next step depends on where the product was purchased.

Welcome to BI/Query 5
Contacting Technical Support
You can report problems and suggest enhancements in BI/Suite
software by contacting Technical Support. Before we can investigate
your problem, we need certain information from you. This
information is outlined on our Web site on the Technical Support
page. You can use the form that’s provided, or you can provide the
information by phone or fax.

Worldwide Tel: +1-613-548-4355 (8:00 am - 8:00 pm ET)


Fax: +1-613-548-7616
E-mail: hbi-support@kingston.hummingbird.com
Web: www.hummingbird.com
FTP: ftp.hummingbird.com

Asia Pacific Tel: +1-613-548-4355


Fax: +1-613-548-7616
E-mail: hbi-support@kingston.hummingbird.com

Australia and Tel: +61-2-9929-4999


New Zealand Fax: +61-2-9956-6442
E-mail: au-bi-support@hummingbird.com

Canada and Tel: 1-800-486-0095 (8:00 am - 8:00 pm ET)


USA Fax: 1-613-548-7616
E-mail: hbi-support@kingston.hummingbird.com

Deutschland Tel: +49-40-79-70-07-23 (09:00 bis 17:00 Uhr)


Fax: +49-40-79-70-07-10
E-mail: de-bi-support@hummingbird.com

France Tél: +33-1-53-34-93-17 (09:00 à 18:00)


Fax: +33-1-53-34-93-05
E-mail: fr-bi-support@hummingbird.com

UK Tel: +44-118-902-9507
Fax: +44-118-978-9325
E-mail: uk-bi-support@hummingbird.com

6 Welcome to BI/Query
Troubleshooting Using the Trace Utility
A trace utility is installed with this software to help us troubleshoot
problems that our customers are having. The trace utility simplifies
problem-solving by monitoring the activity of our products. If
you’re having a problem with the software, Technical Support will ask
you to run the trace utility, reproduce the problem you’re having, save To make the trace
the trace information, and send them the resulting trace file. Technical utility easy to use
and administer,
Support will step you through the process and provide additional
you can run it on
information if necessary. only one machine at a time. If
you try to open the utility on
When your problem involves a BI/Suite desktop application, you must another machine running
run the trace utility on the machine that’s exhibiting the problem. BI/Suite components, a mes-
sage box appears, stating the
To run the trace utility name of the machine where
the utility is already running.
1 Double-click the trace.exe file in Program Files\Hummingbird BI\
Utility.
2 Make sure tracing is enabled. (If it is, a check mark appears beside
the File>Tracing Enabled command.)
3 Make sure Corba tracing is disabled and Com tracing is enabled.
(Choose File>Preferences. In the Preferences dialog box, click the
Disable Corba Messages check box to disable Corba tracing. Make
sure the Disable Com Messages check box isn’t selected.)
4 Run a BI/Suite application. (In BI/Query, click the system icon
above the File menu, then choose Debug. In the Debug Control
Panel dialog box, choose Trace Utility (via Com) from the Trace
Output list, then click OK.)
5 Reproduce the problem.

Professional Services
Hummingbird supports its products by offering consulting and training
services worldwide. Working alongside your own technical and non-
technical staff, our Professional Services group can help you identify
areas where improved information management can enhance your
business performance. And we can supply the expertise you need to
bring these opportunities to fruition.

Welcome to BI/Query 7
Hummingbird offers standard training to help users and administrators
become confident using our products. We also design courses that are
tailored to meet your organization’s specific needs. These courses can
take place at your workplace or at our own training centers.

Contacting Professional Services


To register, or for more information, pricing, and detailed course
outlines, contact Hummingbird Professional Services at:

Voice +1-613-548-4355 ext. 1700

Fax +1-613-548-7801

E-mail proservices@hummingbird.com

Web www.hummingbird.com

The Business Intelligence Product Line


Hummingbird’s Business Intelligence product line offers an end-to-end
solution that encompasses the transformation of data from one source
to another as well as querying, reporting, and analysis of data.

Hummingbird Genio Suite


Hummingbird Genio Suite is an information broker that allows
organizations to transform and exchange data from any existing data
source into any other decision support system (data warehouses or data
marts) or business application in your organization. With its modular
architecture, superior data transformation capabilities, change
management features, and data quality controls, Genio gives
organizations the control, flexibility, and efficiency they need to handle
complex transformations and ensure the quality, accuracy, and
timeliness of corporate information.

8 Welcome to BI/Query
Genio Suite includes the following components:

Genio Engine A high-speed, multi-threaded broker-


based transformation engine.

Genio Designer A multi-user graphical development


environment for designing data
transformation and exchange processes.

Genio Repository An object-oriented, open repository


that can reside in any relational database
management system.

Genio Scheduler A sophisticated time- and event-based


scheduler.

Genio Met@Data A design tool for creating customized


Studio views of metadata for business users.

Genio Met@Data A metadata browser for business users.


Explorer

Genio MetaLink A suite of connectivity bridges that


enables the extraction and
transformation of data and metadata
from enterprise resource planning
(ERP) applications and repositories such
as SAP.

Hummingbird BI/Suite
Hummingbird BI/Suite is a fully integrated, scalable business intelligence
solution that allows users to better understand their business by asking
questions about information in the corporate database, analyze the
answers for more effective decision-making, present that information in
reports, and distribute it in a variety of ways, including over the World
Wide Web.

Welcome to BI/Query 9
Hummingbird BI/Broker

Hummingbird BI/Broker is the cornerstone of Hummingbird BI/Suite.


It’s an application server that provides shared services and a common
repository of information that users can access using Hummingbird BI
desktop applications, their Web browsers, or certain mobile computing
devices. BI/Broker manages security, scheduling, and distribution
services in a centrally managed client/server environment.

BI/Broker includes the following key components, which are fully


integrated with Hummingbird BI desktop applications:

BI/Broker Admin Manages the BI/Broker configuration.

BI/Broker Provides the central storehouse of data


Repository models, queries, results sets, reports, and
data sources.

User and Group Provides user, group, and role-based security.


Manager

Scheduler Schedules queries, reports, and HyperCubes


and distributes the results.

Hummingbird BI/Web

Hummingbird BI/Web uses the services of BI/Broker to provide query,


reporting, and Online Analytical Processing (OLAP) capability to Web
users without requiring the installation of any desktop software.

Hummingbird BI/Query

Hummingbird BI/Query is an ad hoc query and reporting tool that


provides a comprehensive solution for accessing, analyzing, and
presenting data in a client/server environment. With its graphical
approach and intuitive interface, BI/Query gives users flexible access to
the data while maintaining organizational control.

10 Welcome to BI/Query
The BI/Query product line consists of four separate applications:

BI/Query Admin The advanced business user’s administrative


tool. It allows users to create data models, use
them to query the corporate database, produce
reports, and update the database.

BI/Query User The business user’s ad hoc query tool. It


allows users to use a data model to query the
corporate database and produce reports.

BI/Query Update An extended version of BI/Query User. It


allows users with special access privileges to
add, modify, and delete information in
corporate databases.

BI/Query Reports A reporting tool installed with BI/Query.


BI/Query Reports can present the data obtained
in BI/Query in tables, crosstabs, and charts.

Hummingbird BI/Analyze

Hummingbird BI/Analyze is an Online Analytical Processing (OLAP)


tool that allows users to analyze information from various business
perspectives. Using BI/Analyze, users can drill up and down through
successive layers of detail to discover trends, patterns, and relationships
in their data. BI/Analyze provides direct connections to a variety of
multidimensional data sources and supports the OLE DB for OLAP
standard. Using BI/Analyze CubeCreator, users can also create their own
multidimensional data sources from detailed, transactional data.

Welcome to BI/Query 11
Contacting Hummingbird Sales
Regional sales offices are located worldwide. For a current list of
contacts and phone numbers, contact Hummingbird Sales at:

Voice Canada and USA: 1-877-FLY HUMM (1-877-359-4866)


Worldwide: +1-416-496-2200

Fax +1-416-496-2207

E-mail getinfo@hummingbird.com

Web www.hummingbird.com

12 Welcome to BI/Query
Basic Concepts

Working with Data Models 15


Data Objects 15
Attributes 16
Relationships 16
Building Queries 17
Buttons 18
Turning Data into Reports 18
Basic Concepts
In order to make informed business decisions, you need to turn the data
in your corporate database into information you can use. BI/Query
provides you with an easy way to do that. It allows you to extract
exactly the information you need using queries based on a BI/Query
data model. You don’t need to learn SQL (Structured Query Language,
the language used for retrieving data from most databases).

Working with Data Models


When you use BI/Query to get information from your database, you
work with a graphical representation of the data called a data model.
Data models may have one or more windows which contain data
objects and relationships.

Data object

Relationship

A data model includes data objects and the relationships between them.

Data Objects
Data objects are rectangular or graphical icons that represent tables in the
database. Each data object includes categories of information found in
that table. For example, a Retailers data object might represent a table
that contains such categories as the retailer’s name, city, country, and
credit limit. These information categories are called attributes.

Basic Concepts 15
Attributes
You specify the categories of information you want from the database
by selecting attributes in a window that opens from the data object.

Data objects display attributes in an attribute window

Attributes represent categories of information to be retrieved from the database.


You can select the ones you want.

Relationships
If you want a data The lines connecting the data objects indicate relationships among data
model to display objects. Data objects connected by a relationship have at least one
diamond relation-
category in common. For instance, the relationship between a
ship icons, choose
Tools>Preferences, then Regional Offices data object and a Staff data object might be that both
select Show Relationships. If contain an “office name” category. Relationships may be shown with a
you want it to display rela- diamond icon and a name as well as a line.
tionship names as well, also
select Show Relationship Data objects can have more than one relationship, so that you can get
Names.
different information using the same data objects. In the example
below, you could use the works in relationship to find information
about an employee who works in a particular department; you could
also use the managed by relationship to find information about an
employee who manages a particular department.

16 Basic Concepts
Building Queries
In order to retrieve information using the data objects and relationships
in a data model, you must first frame a question, called a query.

To build a query, you need to know the kind of information you want.
For instance, do you want information about products sold or about
the people who sold the products? Are you trying to find out about
receivables or about credit limits? You also must decide what portion of
the available information you want. Do you want sales figures for this
year only, or the last ten years, or just the current quarter? Do you want
receivables for all retailers, or just for those in, say, Japan?

Once you frame the question, you can begin to build the query. The
first step is selecting attributes from at least one data object. For some
queries, that may be all you need to do. For most, however, you will
go on to qualify, or restrict, the query in various ways in order to see
just the information that interests you.

Basic Concepts 17
Selected attributes specify what to Qualified attributes filter
retrieve from the database the information

You may also want to refine the query in other ways. Once you’ve
built it, you can submit it to the database or save it for later use.

Buttons
Data models may contain buttons to automate processes including
querying. You can create your own buttons to run queries. (See the
BI/Query Data Models Guide.)

Turning Data into Reports


Once you’ve gathered the data you want by querying, you may need to
present it in a report. BI/Query Reports provides a flexible reporting
environment that includes tables, crosstabs, charts, and maps to answer
every type of business question. BI/Query Reports is installed with
BI/Query. (For more information about this reporting tool, see the
BI/Query Reports user documentation.)

18 Basic Concepts
Getting Started

Installing BI/Query 21
Starting BI/Query 21
Finding the Administrator Layer in a Split
Data Model 23
Connecting 24
Using a Default Connection File 25
Using Another Connection File 25
Entering Additional Information 26
Disconnecting 26
Getting Started
This chapter describes how to start BI/Query, open a data model, and
connect to the DBMS.

Installing BI/Query
For installation instructions, see the BI/Query Installation Guide.

Starting BI/Query
BI/Query consists of three applications: User, Update, and Admin.
When you start BI/Query, the BI/Broker Login dialog box may
appear. This indicates that your corporate querying environment
includes a central storehouse for data models, queries, results, and
reports called the BI/Broker Repository. You can log in to use the
repository, or you can work offline.

If you log in, you can publish data models, queries, and reports to the
repository, set permissions on them, and retrieve them. You can also
schedule queries and reports. (For more information, see the BI/Broker
Publishing and Scheduling Guide.) If you work offline, you don’t have
access to the repository. It doesn’t affect your ability to connect to the
database; you can still submit queries and work with the results.

To start BI/Query
1 Choose Start>Programs>Hummingbird BI Suite>BI-Query User
(or BI-Query Update or BI-Query Admin).
2 If the BI/Broker Login dialog box appears, to log in to the
repository, type your user name and password. If the Domain text
box appears and is enabled, type your domain name into it. (If
you’re unsure what information to provide in this dialog box, check
with your administrator.) Click OK.
OR

Getting Started 21
If you need to To work without access to the repository, click Work Offline.
publish, retrieve,
schedule, or set
permissions on
your work, you can log in to
the repository at any time.
Choose File>Work Online.

3 In the Welcome to BI/Query window, click the icon for the type
of data model you want to open. (The Repository Data Model
option is available only if you’ve logged in to the repository. The
New Data Model option is available only in BI/Query Admin.)

4 To open a data model you recently used, click Recent Data Model.
In the Recent Models dialog box, select the data model.

22 Getting Started
5 To open a data model stored on your computer or local network,
click Local Data Model. In the Open Data Model dialog box, open
the data model. (If a message appears, stating that a newer version of
the data model exists either in the repository or in the database,
click Yes to open the newer version.)

6 To open a data model stored in the repository, click Repository


Data Model. In the Retrieve dialog box, locate the data model,
then click Retrieve. (If a message informs you that a newer version
of the data model exists in the database, click Yes to retrieve it.)

Finding the Administrator Layer in a Split


Data Model
A data model is either a split or a combined data model. A split data
model is stored as two files — the administrator-layer file with the
extension .gqa and the user-layer file with the extension .gqu.

Getting Started 23
If you can’t select No matter which BI/Query application you use, if you open a split
a button or orna- data model, it’s the user-layer file that opens. The user-layer file contains
ment in Design
Mode using a path to the administrator-layer file, which allows BI/Query to
BI/Query User or BI/Query combine the two layers. Having two layers allows users to make
Update, it’s because you’re customizations to individual versions of the model without changing
using a split data model and
the core model.
the object is stored in the
administrator layer. Users can
However, if the administrator-layer file has been moved or renamed,
select and modify only ele-
ments in the user layer. Any the link between it and the user-layer file will be broken. If that
item in a dialog box that has a happens, when you open a split data model, BI/Query can’t find the
lock icon beside it was created administrator layer and displays a message. You need to locate the file,
by the administrator and also
then save the data model to save the link to the new location.
can’t be modified by the user.

To find the administrator layer when it’s been moved or renamed


1 In the message box, click Find It.

2 In the Open Data Model dialog box, open the administrator-layer


file. (If you can’t locate it, contact your administrator.)
3 Choose File>Save.

Connecting
Before it queries the database, BI/Query must connect to the database
management system (DBMS). To do this, it uses a connection file that
contains information for that particular connection type. Typically, the
person who creates a data model includes at least one connection file
with it and sets it up to automatically connect to the DBMS each time
you open it or each time you submit a query.

If you submit a query using a data model with an associated connection


file, BI/Query makes the connection. You can also connect yourself by
using a default connection file or by specifying another file.

24 Getting Started
If the data model doesn’t have a connection file associated with it, you
need to see the person who created it for information on obtaining
one. (You can also create your own connection files. See the BI/Query
Data Models Guide.)

Using a Default Connection File


If the data model you’re using has a default connection file, connecting
is fast and easy.

To connect using a default connection file


1 Choose Host>Connect.

Using Another Connection File


If the data model you’re using doesn’t have a default connection file, or
if you don’t want to use the connection file assigned as the default, you
can specify another connection.

To connect using another connection file


1 Choose Host>Connections.
2 In the Connections dialog box, select a connection file from the
Connection Names list.

3 Click Connect.

Getting Started 25
Entering Additional Information
If you need to supply any information that isn’t included in the
connection file, such as a password or user ID, you’re prompted for it
when you connect. If you’re unsure what information to supply, check
with your administrator.

If you’ve been assigned the Cache Passwords permission, any additional


information that you supply is stored in memory until you close the
data model. (While the permission refers to passwords, it actually affects
all missing connection information.) If you use more than one
connection file for a data model, additional information is stored for
each connection file.

To enter connection information


1 If the Enter Connection Information dialog box appears, type the
required information, then click OK.

Disconnecting
When you no longer need access to the DBMS, it’s good practice to
disconnect from it to reduce the load on the database server.

To disconnect from the DBMS


1 Choose Host>Disconnect.

26 Getting Started
Building Queries

Selecting Attributes 30 Performing Calculations 47


Qualifying Queries 32 Applying Functions to Attributes 47
Using the Qualification Tree 32 Specifying Functions 50
Qualification Text Box 33 Specifying a Group Order 51
List Icon 33 Grouping without Functions 54
Data Values Icon 34 Creating Attributes That Perform Calculations 55
Operator List 34 Ordering Query Results 58
Condition Box 35 Ordering Columns 58
Using the Data Values Icon 35 Sorting Rows 60
Data Values and Data Values Lists 35 Attribute Window Sort Box 61
Prompts 37 Sort Order Dialog Box 63
Variables 38 Submitting Queries 64
Reversing Qualifications 39 Saving Queries 64
Applying Multiple Qualifications 40 Loading Queries 66
Combining Qualifications 41 Saving Results 67
Restricting Qualifications with Operators 42
Making Comparisons 43
Matching Character Strings 44
Matching Items in a List 45
Finding a Range of Values 45
Finding Unknown Values 46
Applying Your Own Operator 46
Building Queries
In order to retrieve information from the database, you need to build You can build
queries (sometimes called ad hoc queries) that ask the questions you want only one query at
a time. To
answered. To build a query, you choose categories of information and remove the cur-
then decide how much of the information you actually want to receive rent query and start a new
in the results. You may want the query to perform calculations on the one, choose Query>New.
data it retrieves before providing you with results. You may also want Even if you’ve submitted or
saved a query, it remains the
to specify how rows are to be sorted and how columns are to be current query until you
ordered in the results. remove it.

You build a query in the attribute window.

Apply a function to
an attribute or
Group or sort results
create your own
calculation.

Qualify with one or more data


values, a prompt, a variable,
another attribute, or a subquery

In the attribute window, you choose categories of information by selecting attributes.


You restrict the amount of information by clicking in the Qualify column and entering
information into the qualification tree. You can also apply a function or a calculation of
your own and specify how results are to be grouped and sorted.

Building Queries 29
Once you’ve built the query you want, you can submit it to the DBMS
right away and save it for later use by yourself and others.

Selecting Attributes
You specify the categories of information you want from the database
by selecting attributes in a data object. (See “Data Objects” on
page 15.) The selected attributes appear as column headings when your
query brings back the information. As soon as you select one attribute,
you have built a query. It is up to you to decide how much more you
want your query to include.

For example, if you select the Name attribute in a Retailers data object
and then submit the query to the database, it brings back the names of
all the retailers in the database table, in a column labeled Name. If you
also select the City attribute in the same data object and submit the
query, it brings back the retailers’ names, in a column labeled Name,
and the city in which each is located, in another column labeled City.

You can select as many attributes as you like in each data object. And
you can select attributes from as many data objects as you like within
one data model window. (If your data model has data objects in more
than one window, you can build separate queries in each window, then
use one of several methods for combining them. See “Combining
Queries” on page 129.)

To select attributes
1 Open a data model.
2 Double-click a data object for which you want to retrieve
information.

30 Building Queries
Double-click a data object to view its attributes

3 In the attribute window, click the attributes that represent the


categories of information you want to retrieve.

4 If an additional data object is connected by a relationship with the


first, you can select attributes for your query from that data object as
well.
5 If your query is complete, choose Query>Submit to submit it to
the database or save it for later submission (see “Saving Queries” on
page 64).
6 If you want to build a new query, choose Query>New.

Building Queries 31
Qualifying Queries
In addition to using attributes to specify the categories of information
you want from the database, you can use attributes to place limits on
the amount of information that you receive. The process of limiting the
information this way is called qualifying the query.

It isn’t necessary to select an attribute in order to use it to qualify a


query. For instance, suppose that you want a list of retailers in France
and the city in which each operates. You select the Name and City
attributes. Since France is the only country you want to include in your
results, you won’t need a column labeled Country. So, although you
qualify the Country attribute to restrict it to France, you don’t select the
Country attribute.

When you submit this query, it brings back from the database a list of
the names and cities of those retailers who operate in France.

Using the Qualification Tree


The qualification tree displays the name of the attribute you’re qualifying
and provides the means of qualifying it. It includes the qualification text
box, the list icon, the data values icon, the operator list, and the
condition box.

Data values
icon
Attribute Operator Qualification List
list text box icon
Condition box

32 Building Queries
Qualification Text Box

You can enter one or more items into the qualification text box to qualify If your database is
an attribute. For example, by qualifying the Country attribute with case-sensitive and
the Case-sensitive
France, Germany, and Spain, you can restrict the results to retailers
Comparisons
located in France, Germany, and Spain. You can type the values you preference is set, when you
want. To enter more than one value by typing, press the Down Arrow type a qualification, the char-
after each. Alternatively, click the list icon, then choose New Entry (see acters must be in the case in
which they are stored in the
“List Icon” on page 33). You can also select the values from a data database. If this preference
values list. (See “Data Values Icon” on page 34.) isn’t set, case isn’t important.

You can enter dates in a variety of formats (such as 1998/1/14,


1.14.1998, or January 14, 1998) as long as BI/Query can
unambiguously determine the dates you enter. When in doubt, use the
default format specified in your Control Panel. (For more information
about specifying date formats, see “Entering Data” on page 71.)

When you’ve finished entering a qualification in the qualification text


box, click outside the qualification tree. If you entered one value, it
appears in the qualification tree; if you entered more than one value,
the values are represented by the list icon.

Single value List of values

Once you’ve entered a qualification, you can view and modify it by


clicking the value or the list icon.

List Icon

You can use the list icon beside the qualification text box to add and
modify entries in a list of qualification values or to delete all entries.
Values that you enter in the qualification text box are displayed in a list
when you click the list icon. By clicking a value in the list, you can
display that value in the qualification text box. Alternatively, use the

Building Queries 33
Up or Down arrow keys on your keyboard to display each value in the
qualification text box.

List icon

Add a new value to the list


Remove all values from the list

Current list of values

Data Values Icon

The data values icon appears beside the list icon. It provides an easy
means of inserting one or more specific values (data values), prompts,
or variables into a qualification. Prompts prompt you for one or more
data values, while variables perform a user-defined operation. (See
“Using the Data Values Icon” on page 35.)

Operator List

Use the operator list in the qualification tree to specify the type of
restriction you want. For example, you can apply the Greater Than (>)
operator to find all the records that have a value greater than the
qualification you specified. (See “Restricting Qualifications with
Operators” on page 42.)

34 Building Queries
Operator list

Condition Box

The condition box appears above the attribute identified in the


qualification tree. If you specify multiple qualifications in a query, you
can use the condition box to combine them (see “Combining
Qualifications” on page 41) or give them the opposite meaning (see
“Reversing Qualifications” on page 39). You can also remove a
qualification from a query: click the condition box, then press Delete.

Using the Data Values Icon


You’ll often want to restrict the results of your queries to one value
(such as “France”) or to some subset of the possible values (such as
“France, Spain, Portugal”). The data values icon in the qualification
tree allows you to do this in one of three ways, by specifying the data
value(s) directly or by means of a prompt or a variable.

Data Values and Data Values Lists

When you qualify an attribute with specific data values (such as


“France” or “Spain”), you can type the values into the qualification

Building Queries 35
text box or you can select them from a list using the Data Values icon
(or choosing Edit>Data Values). Selecting from a list of data values
avoids potential uncertainty about what values actually exist in the
database and about capitalization and spelling.

Unless the designer of the data model has disabled data values, clicking
the data values icon, then choosing Data Values, submits a default query
which retrieves all the unique values in the database for that attribute.
The values are displayed in the Data Values dialog box, where you can
select the one(s) you want to enter into a qualification.

If data values for an attribute haven’t been disabled, clicking the data values icon and
choosing Data Values displays all the values for the attribute stored in the database.

Alternatively, users may choose to substitute data values lists for the
default data values query.

In this qualification tree, clicking the Data Values icon displays a list of values.

36 Building Queries
If data values haven’t been disabled for an attribute, you can access all
the data values in the database instead of just those provided by the data
values list by choosing more from the list, then clicking Load All in the
Data Values dialog box. (For more detailed information on creating and
using data values lists, see “Data Values Files” on page 83.)

To qualify an attribute with one or more data values


1 In an attribute window, click the Qualify box for an attribute.
2 With the cursor in the qualification text box, type the data value(s)
you want to use (press the Down Arrow after each if typing more
than one). Or, click the data values icon and choose Data Values; in
the Data Values dialog box or data values list, select the values you
want, then click Insert.
3 If your query is complete, choose Query>Submit to submit it to
the database or save it for later submission (see “Saving Queries” on
page 64).

Prompts

If you create queries for reuse, whether by yourself or by others, you


may want to qualify an attribute with a prompt. A prompt will require
the person submitting the query to supply the appropriate value(s) at
the time the query is submitted. That way, the same query can retrieve
a different set of results each time. For instance, when you want to
know about retailers in France, you respond to the prompt with the
value “France” and when you want to know about retailers in Canada,
you respond to the prompt with the value “Canada”. In the prompt
dialog box, you can type the name of a country or choose from a data
values list of countries (see “Data Values and Data Values Lists” on
page 35).

Building Queries 37
When a query You can build a query with multiple prompts, allowing users of the
prompts you for query to quickly zoom in on increasingly detailed information when
one or more val-
ues, you can insert they submit the query. For more detailed information on creating and
them, or you can leave the using prompts, see “Prompts” on page 96.
prompt blank. (Leaving it
blank returns all of the possi- To qualify an attribute with a prompt
ble values for the attribute.)
To view the query’s SQL, in 1 In an attribute window, click the Qualify box for an attribute.
the attribute window, choose 2 With the cursor in the qualification text box, click the data values
Query>Show, then click icon, then select Prompts from the list.
Show Prompt Values. If you
specified prompt values, 3 In the Prompts dialog box, select a prompt. (If the prompt you
they’re displayed in the SQL. want isn’t listed, you can create it. See “Creating Single Prompts”
If you didn’t, the prompt on page 97.)
qualification is removed from
the WHERE clause to reflect
the actual query that will be
submitted to the DBMS.

4 Click Insert Prompt.


5 If your query is complete, choose Query>Submit to submit it to
the database or save it to submit later. (See “Saving Queries” on
page 64.)

Variables

You can also qualify a query with a variable that silently performs an
operation you define and supplies the result as the qualification. For
instance, you might want a query to provide information for the
current date only. You can qualify the query with a variable that

38 Building Queries
determines the date at the time the query is being submitted and uses
that date to restrict the information that is returned from the database.
That way, there’s no need to prompt the person submitting the query
for today’s date. (For more detailed information on creating and using
variables, see “Variables” on page 107.)

To qualify a query with a variable


1 In an attribute window, click the Qualify box for an attribute.
2 With the cursor in the qualification text box, click the data values
icon, then select Variables from the list.
3 In the Variables dialog box, select a variable. (If the variable you
want isn’t listed, you can create it. See “Creating Variables” on
page 108.)

4 Click Insert Variable.


5 If the query is complete, choose Query>Submit to submit it to the
database or save it to submit later. (See “Saving Queries” on
page 64.)

Reversing Qualifications
When you want to exclude certain information from a query, or when
it’s easier to specify the information you don’t want rather than the
information you do (for example, all retailers except those in

Building Queries 39
Germany), you can qualify the query to have the opposite meaning to
the condition specified.

To reverse a qualification
When you reverse 1 In an attribute window, click the condition box above a
a qualification, the qualification.
word not appears
in front of the 2 Choose Query>Qualification>Negate Clause.
condition box. If you change
your mind about the restric-
tion, click the word not to
remove it.

Applying Multiple Qualifications


When you qualify more than one attribute, or when you qualify the
same attribute more than once, you can specify whether the query must
satisfy both qualifications or either one.

To apply multiple qualifications


1 Qualify one or more attributes with one or more qualifications.
(Add a new qualification to an attribute you have already qualified
by clicking the Qualify box again.)
2 To have a query satisfy both qualifications, leave the word and
between them in the qualification tree.

40 Building Queries
OR
To have the query satisfy either qualification, click the word and to
change it to or.

Combining Qualifications
When you’ve specified two or more qualifications in a query, you can
combine them so that they take precedence over those that aren’t
combined. For example, the qualification Country = France and
Country = Germany and Credit Limit < 60,000 is ambiguous. It’s
unclear whether its purpose is to produce a) retailers located in France
or Germany, all with a credit limit of under $60,000, or b) retailers
located in Germany with a credit limit of under $60,000 plus retailers
located in France. To avoid ambiguity, you can combine this query to
read: (Country = France or Country = Germany) and Credit Limit <
60,000; the results will consist of all retailers located in France or
Germany, all of whom have a credit limit of under $60,000.
Combining qualifications in this way is the equivalent of using brackets
in a mathematical expression — for example, 2 x (3-1) — to indicate
the part of the expression that should be calculated first.

Building Queries 41
To combine qualifications
1 In an attribute window, select the condition boxes above the
qualifications you want to combine.

2 Choose Query>Qualification>Combine.
When a qualifica- 3 To change the condition from and to or, click the word and.
tion is combined,
you can separate
it. Click the con-
dition box above it, then
choose Query>Qualifica-
tion>Uncombine.

Restricting Qualifications with Operators


When you qualify an attribute, BI/Query displays the = operator in the
qualification by default, then finds all the records in the database that

42 Building Queries
match the qualification(s) you specify. For example, by setting the
Country attribute equal to Spain, the results include only retailers
located in Spain.

Using the operator list in the qualification tree, you can apply other
operators to restrict a qualification. Keep in mind that the >, >=, <,
and <= operators allow you to insert a single value when you submit
the query; the BETWEEN and NOT BETWEEN operators require
two values (for an upper and lower range); the =, IN, NOT IN, and
<> operators allow you to insert one or more values.

Operator list

Making Comparisons

When you need to compare values to find, for example, those that are
larger or smaller, earlier or later in the alphabet, or equal to a value, you
can specify the value on which you want to base the comparison in the
qualification text box and apply the appropriate comparison operator.
While comparisons are typically applied to numbers, they can also be
applied to characters and dates. With characters and dates, < means
earlier in the alphabet or in chronological order; > means later.

Building Queries 43
This Qualification Results in This

Credit Limit = 2,000 Credit limits exactly equal to 2,000.

Credit Limit != 2,000 All credit limits except those equal to


2,000.

Credit Limit < 2,000 Credit limits less than 2,000.

Credit Limit <= 2,000 Credit limits less than or equal to 2,000.

Credit Limit > 2,000 Credit limits greater than 2,000.

Credit Limit >= 2,000 Credit limits greater than or equal to


2,000.

Matching Character Strings

You may not be sure how an item is stored in the database, or you may
want to find records for which there is some kind of pattern. For
example, you may need information about a retailer and aren’t sure of
the spelling of the name but know that it begins with Cars. (Is it
Carson, Carsen, Carsin?) Similarly, you may need a list of retailers
whose postal code is 3011.

You can specify the characters you want to match in the qualification
text box and apply the Begins with, Contains, or Ends with operator.

When you submit the query, BI/Query looks for all instances of values
that match the qualification you specified. You can also type the %
symbol into the qualification text box to find a match for any string of
characters, regardless of where it falls.

The Does not begin with, Does not contain, and Does not end with operators
function in the same way as their counterparts but allow you to find
items that don’t contain the character string you specify. For example,
you can use them to find retailers whose postal code isn’t 3011.

You can apply these operators to character strings, not numbers or dates.

44 Building Queries
This Qualification Results in This

Retailer name Begins Sweet Indulgence, Sweets to Go.


with Sweet

Retailer name Contains Peppermint Twist, Dulces Irresistbles.


ist

Zip/Postal code Ends F-3011, D-3011, DK-3011.


with 3011

Retailer name does not All retailer names except those


begin with Sweet beginning with Sweet.

Retailer name Does not All retailer names except those


contain ist containing ist.

Zip/Postal code Does not All Zip and postal codes except those
end with 3011 ending with 3011.

Matching Items in a List

When you qualify an attribute with a list, BI/Query automatically


applies the IN operator to the list. The IN operator allows you to find
all records that match any one item in the list. You can also find items
that don’t match those in a list.

This Qualification Results in This

Country IN France, France, Germany, and Spain.


Germany, Spain

Country NOT IN All countries except France, Germany,


France, Germany, Spain and Spain.

Finding a Range of Values

You can qualify an attribute with a range of values to obtain results


within a particular range. The range is inclusive, retrieving the lower
value and the upper value as well as the values in between. To do so,

Building Queries 45
enter the values as a qualification list (see “List Icon” on page 33) and
apply the BETWEEN operator. You can also find results that are
outside a particular range by applying NOT BETWEEN. If you qualify a
character field, be sure you use the case in which the value is stored in the
database.

This Qualification Results in This

Credit Limit Credit limits between and including


BETWEEN 2,000 and 2,000 and 5,000 (2,000, 2,456, 4,646,
5,000 5,000, and so on).

Credit Limit NOT Credit limits outside this range (100,


BETWEEN 2,000 and 1,400, 5,001, 6,111, and so on).
5,000

Finding Unknown Values

A NULL value occurs when no value has been entered into the
database. It doesn’t represent a zero or a character space but is instead a
placeholder for missing information. Because NULLs don’t match
anything, you can’t retrieve them using standard comparison
qualifications such as Greater Than or Less Than. To include or
exclude rows for which information hasn’t been recorded, apply the IS
NULL or IS NOT NULL operator to an attribute.

This Qualification Results in This

Credit Limit IS NULL Credit limits for which there is no value.

Credit Limit IS NOT Credit limits for which there is a value.


NULL

Applying Your Own Operator

In addition to applying the standard SQL operators provided in


BI/Query, you can restrict a qualification using any other operator that

46 Building Queries
your DBMS (database management system) supports. (For information
about the operators your DBMS supports, see the documentation for
your DBMS.)

To apply your own operator


1 In an attribute window, select User defined from the operator list in
the qualification tree.
2 In the Enter Text dialog box, specify an operator.

3 Click OK.

Performing Calculations
You can use queries to perform basic calculations such as summing or
averaging results by applying a function to an attribute. You can also
carry out more sophisticated calculations by applying a user-defined
calculation to an attribute.

Applying Functions to Attributes


Aggregate functions are mathematical operations that allow you to calculate
summary values from a set of values for an attribute. For example, you
can retrieve retailers’ total sales by applying the SUM function to the
Invoice Amount attribute. Different functions are available depending
on the attribute, DBMS, and data type you’re using.

When you apply an aggregate function to an attribute, BI/Query


automatically groups all the other attributes in the query in the order in
which you selected them. (If this order isn’t appropriate to your needs,
you can change it. See “Specifying a Group Order” on page 51.)

Building Queries 47
Grouping organizes the data into sets and retrieves a summary value for
each set. All selected attributes to which functions haven’t been applied
are grouped to ensure that the results set doesn’t calculate a summary
value for individual members of the group. (To group attributes
without applying functions, see “Grouping without Functions” on
page 54.) The following example shows how grouping works with
aggregate functions.

Suppose the database contains the following data about retailer sales:

Name City Invoice Amount

Sterling Ottawa $3000

Triteck Toronto $1000

Billings Toronto $3000

Sterling Ottawa $1000

Billings Toronto $4000

Saddler Toronto $5000

Triteck Ottawa $2000

Triteck Toronto $3000

If you want to retrieve a list of retailers, cities, and total retailer sales,
you might formulate a query in which you select the Name, City, and
Invoice Amount attributes (in that order) and apply the SUM function
to Invoice Amount. When you submit the query, the DBMS organizes
the data into groups (first by Name, then by City). Each row of results
in a group has identical values except the attribute to which the
function is applied.

The table below shows how the DBMS groups the data. The rows for
Billings, Toronto, represent one group, the row for Saddler, Toronto,
represents another group, and so on.

48 Building Queries
Name City Invoice Amount

Billings Toronto $3000

Billings Toronto $4000

Saddler Toronto $5000

Sterling Ottawa $1000

Sterling Ottawa $3000

Triteck Ottawa $2000

Triteck Toronto $1000

Triteck Toronto $3000

The DBMS then applies the sum to each group. For most DBMSs,
when the results are displayed, each group is organized alphabetically,
numerically, or chronologically. The table below shows how BI/Query
displays the results. Groups are organized first alphabetically by name,
then alphabetically by city for retailers with the same name (such as
Triteck) but located in different cities.

Name City SUM Invoice Amount

Billings Toronto $7000

Saddler Toronto $5000

Sterling Ottawa $4000

Triteck Ottawa $2000

Triteck Toronto $4000

Building Queries 49
Specifying Functions

You can choose from a wide range of functions to calculate the results
you want.

Apply This Function To Do This

none Leave the Function box blank.

AVERAGE Retrieve the average of all the non-null


values of an attribute or the average of
each group.

MAXIMUM Retrieve the maximum value of an


attribute in the results set or by group. (In
character data, this is the last value in the
list; for dates, it’s the most recent date, for
numbers, it’s the highest number.)

MINIMUM Retrieve the minimum value of an


attribute in the results set or by group.
(In character data, this is the first value
in the list; for dates, it’s the earliest date;
for numbers, it’s the lowest number.)

SUM Retrieve the sum of all the non-null


values of an attribute or the sum of each
group.

COUNT Retrieve the number of values that


aren’t NULL (missing) values of an
attribute or the number in each group.

AVERAGE DISTINCT Retrieve the average of all the values of


an attribute or the average of each
group, ignoring any duplicates.

SUM DISTINCT Retrieve the sum of all the values of an


attribute or the sum of each group,
ignoring any duplicates.

50 Building Queries
Apply This Function To Do This

COUNT DISTINCT Retrieve the number of values that


aren’t NULL (missing) values of an
attribute or the number in each group,
ignoring any duplicates.

Calculation Add calculated attributes that perform


user-defined calculations in a query.
(See “Creating Attributes That Perform
Calculations” on page 55.)

To apply a function to an attribute


1 In an attribute window, click the attributes you want.
2 Click the Function box for an attribute, then select a function from
the list.
3 To group the data in a different order than the order in which you
selected the attributes, click the Group box for the remaining
attributes. (The function is applied after the results are grouped.)

This query calculates the average of all retailer sales.

Specifying a Group Order

Whenever you select more than one attribute for a query and then
either apply an aggregate function to at least one attribute or group at
least one attribute (see “Grouping without Functions” on page 54), the

Building Queries 51
When you group remaining attributes must also be grouped. BI/Query automatically
attributes, you can groups attributes in the order in which you selected them. You can
include a column
change the group order by clicking the Group boxes in the attribute
that counts the
number of rows in each window. For example, if you select the Name, City, and Invoice
group. Choose Query> Amount attributes (in that order), apply the SUM function to Invoice
Modifiers>Count All. Amount, and then run the query, BI/Query will group the Name
attribute first, then the City attribute. The results are grouped first by
Name of retailer.

If you click the Group box for City for the same query, a “1” appears
in the Group box to indicate that this attribute will be grouped first.
When you submit the query, it retrieves the names and cities of retailers
along with their total sales, as before, but now the total sales are
grouped first by city, then by retailer name.

If you look at the attribute window, you’ll see that “2” appears in the
Group box for the Name attribute and “3” in the Group box for the
Invoice Amount attribute. BI/Query has automatically grouped the
remaining attributes in the order in which you originally selected them.

52 Building Queries
Grouping before Calculating a Function

When you apply a function to an attribute, you can qualify the attribute
in the qualification tree in order to group results before calculating the WHERE Clause
When you group results
function. (See “Qualifying Queries” on page 32.) For example, in before calculating the
order to retrieve retailers’ largest sales, you might include the Retailer function, the SQL for the
Name and Invoice Amount attributes, qualify Invoice Amount to be query contains a WHERE
clause.
greater than $50,000, and apply the SUM function to it.

When you submit this query, BI/Query eliminates the records that
don’t meet the criteria you specified, groups the results, and calculates
the sum for each group. That is, it finds all sales that are greater than
$50,000, groups them by retailer name, then sums them.

Grouping after Calculating a Function

When you apply a function to an attribute, you can qualify the attribute
HAVING Clause
with a group qualification in order to group results after calculating the
When you group results
function. The qualification is applied to the entire query, after all after calculating the func-
aggregate functions have been calculated (including any calculated tion, the SQL for the
attributes that are treated as aggregates) and the appropriate attributes query contains a HAV-
ING clause.
have been grouped. For example, instead of finding retailers’ largest
sales, you can find the largest retailers by summing all sales by retailer
first, then eliminating the sums that don’t meet your criteria. (For
information about calculated attributes, see “Creating Attributes That
Perform Calculations” on page 55.)

To group results after calculating a function


1 In an attribute window, click the Function box for an attribute,
then select a function from the list.
2 Choose Query>Qualification>Group.
3 In the Group Qualification dialog box, under Columns, select the
column to which you want to apply the group qualification.
4 Click Move, then type the qualification into the available text box.

Building Queries 53
This list displays the Count function,
all columns to which an aggregate
function has been applied, and any
calculated attributes that are
treated as aggregates.

The SUM function for the Invoice Amount attribute is qualified with >50000 to
retrieve a list of total sales greater than $50,000.

5 To include a prompt in the qualification, click Insert Prompt, then


use the Insert Prompt dialog box to specify it. (For more
information about prompts, see “Prompts” on page 96.)
6 To include a variable in the qualification, click Insert Variable, then
use the Insert Variable dialog box to specify it. (For more
information about using variables in queries, see “Variables” on
page 107.)
7 To include the database name of another attribute to which the
qualification refers, click Insert DB Name, then use the Insert DB
Name dialog box to specify it.
8 Click OK.

Grouping without Functions

Grouping is most often used with functions. But you can group
attributes without applying functions. In this case, grouping is similar to
using the Modifier>Distinct command to eliminate duplicates. It
divides a table into groups and returns one row for each group. For
example, a query in which the Country attribute is selected retrieves all
countries in the Retailers table.

54 Building Queries
SQL for the Query Results

select retailers.country Canada


from retailers Canada
France
Australia
France
USA
USA
Canada
Australia

If you group by Country, the results display one row for each group.
(Depending upon the DBMS, the results may be sorted alphabetically.

SQL for the Query Results

select retailers.country Australia


from retailers group by Canada
retailers.country France
USA

Creating Attributes That Perform Calculations


BI/Query allows you to add calculated attributes to a data object. A If you’re using a
calculated attribute performs a user-defined calculation in a query. The Teradata connec-
tion via WinCLI
calculation can be based on more than one attribute from more than and you’re not
one data object in a design window. For example, a data object might using ODBC, you need to
include Unit Price and Unit Cost attributes that retrieve a product’s identify the type of data the
calculated attribute creates.
market price and production cost, respectively. By creating a new
For all other connections, you
attribute that calculates Unit Price minus Unit Cost, you can determine can either specify a data type
the profit made on each product. You can also apply a function (such as or use the default Automatic.
an average) to an attribute in the calculation.

In a combined data model, users can edit or delete any calculated


attribute. In a split data model, users can edit or delete only calculated
attributes that they create, not those the administrator provides.

Building Queries 55
To create an attribute that performs a calculation
You can easily 1 In an attribute window, click the attributes you want.
edit and delete the
2 Click the Function box for the attribute below which you want to
calculated
add the calculated attribute, then select Calculation from the list.
attributes you cre-
ate. Click the Function box in 3 In the Edit Computed Attribute dialog box, type a name for the
the attribute window, then attribute into the Name text box.
select Edit Calculation or
4 In the Expression text box, specify a calculation. (Type it in or use
Delete Calculation from the
list. the keypad. Add a space between each item.)

The expression displays


the database names of
the attributes

The Profit attribute calculates Unit Price minus Unit Cost to give profit per product.

5 To include an attribute in the expression, select the corresponding


data object from the Table/Attributes list, select an attribute, then
click Insert Attribute.
6 To ensure that the other attributes in the query are grouped when
the calculated attribute is used in a query, click Aggregate. (See
“Applying Functions to Attributes” on page 47.)
7 To include a function in the expression, click Insert Function, then
use the Insert Function dialog box to specify a function.

56 Building Queries
Choosing a Function
The Insert Function dialog
box displays a list of built-
in functions. For certain
DBMSs, a list of scalar func-
tions appears under Other
Functions. (A scalar func-
tion takes a predefined
number of parameters —
usually one or two — and
produces a value for each
result in turn. Aggregate
functions are often used
with a group by clause; sca-
lar functions aren’t.)
You can use most scalar
functions available in your
DBMS even if they don’t
appear under Other Func-
tions. Type the function
into the Expression text
box. (Check your DBMS
documentation for the
correct format.)

The Average Profit attribute calculates the average profit made on each product.

8 To specify a data type for the calculated attribute and whether it’s
numeric or character, click Data Type, then use the Choose Data
Type dialog box to specify the information.

9 In the Edit Computed Attribute dialog box, click OK.

Building Queries 57
Ordering Query Results
You can edit any In addition to selecting attributes, qualifying the query, and using the
operations that query to apply functions or your own calculations, you can group and
you perform on
query results
sort the information.
(including ordering columns
and sorting rows) from the
Super Query window. See Ordering Columns
“Editing an Operation” on
page 139. When the results of a query are returned, columns are displayed in the
order in which you selected the corresponding attributes in the
attribute window. For example, say that you select first the Name and
then the City attribute in a Retailers data object, then submit the
query. The results look like this:

You can order the columns so that City comes first, then Name. The
results look like this:

You can change the column order before you submit the query or after
you have results. When you change the order before submitting the
query, the DBMS does the ordering. You place fewer demands on the
DBMS by changing the order in the results, since BI/Query does the

58 Building Queries
reordering. However, if you change the column order in the results,
you can’t save the query as a data values query file (see “Creating Data
Values Query Files” on page 90) and you can’t save the SQL for the
query as a text file (see “Saving Results to a File” on page 157.)

To order columns before submitting a query


1 In an attribute window, choose Query>Column Order.
2 In the Column Order dialog box, click a column under Ordered If many columns
Columns, then click First, Last, Up, or Down to establish the order are displayed
you want. under Ordered
Columns, start by
clicking Unorder All to move
all the columns under Unor-
dered Columns. Click each
column, then click Move to
move it to Ordered Columns
in the order you want.

3 Click OK.

To reorder columns after you have results


1 In a results window, choose Results>Reorder Columns.
2 In the Column Order dialog box, click a column under Visible
Columns, then click First, Last, Up, or Down to establish the order
you want.

Building Queries 59
3 Click OK.

Sorting Rows
When you submit a query, the rows of results are displayed as the
DBMS returns them from the database, unless you specify a different
way of sorting them. For example, suppose that you select the Name
and City attributes in a Retailers data object, then submit the query.
The first ten rows of results as they come back from the database look
like this:

If you sort the rows alphabetically by Name, the first ten rows look like
this:

60 Building Queries
If you choose to sort the rows by City, the results look like this:

Rows are sorted in ascending alphabetical (A, B, C,...), numerical (1, 2,


3,...), or chronological (January 4, February 8, March 2,...) order, as
appropriate. They can also be sorted in descending (reverse) order.

Attribute Window Sort Box

The quick way to sort attributes while building the query is to use the
Sort boxes in the attribute window. Query results will be sorted first by
the data returned for the attribute with 1 in its Sort box, then by the
data returned for the attribute with 2 in its Sort box, and so on.

For example, suppose that you select the Name and Credit Limit
attributes in a Retailers data object, then click the Sort boxes for Credit
Limit and Name, in that order. When you submit the query, the results
are sorted numerically by credit limit first, then alphabetically by name.

Building Queries 61
You can sort attributes from more than one attribute window or in
reverse order; you can also sort the results after you’ve submitted the
query. (See “Sort Order Dialog Box” on page 63.)

To specify a sort order in an attribute window


1 In an attribute window, click the attributes by which you want to
sort.
2 Click the Sort box for each attribute in the order you want to sort
by it.

The number 1 in the Sort box for Credit Limit indicates that the rows will be sorted by
credit limit first; the number 2 in the Sort box for Name indicates that the rows will be
sorted by Name second.

62 Building Queries
Sort Order Dialog Box

Using the Sort Order dialog box, you can specify a sort order before
you submit the query or after you have results. When you specify the
sort order before submitting the query, the DBMS does the sorting.
You place fewer demands on the DBMS by specifying the sort order in
the results, since BI/Query sorts the results. However, if you specify
the sort order in the results, you can’t save the query as a data values
query file (see “Creating Data Values Query Files” on page 90) and you
can’t save the SQL for the query as a text file (see “Saving Results to a
File” on page 157.)

To specify a sort order in the Sort Order dialog box


1 In an attribute window, click the attributes you want, then choose For a fast way of
Query>Sort Order. Or, in a results window, choose displaying the Sort
Results>Filter>Sort. Order dialog box
from an attribute
2 In the Sort Order dialog box, under Selected Columns, select those window, double-click the
you want to sort by, then click Move. Sort box for an attribute.

Sorting first in reverse (descending) numerical order by credit limit, then


alphabetically by retailer name.

3 To determine the order, under Sort Order, select columns and click
First, Last, Up, or Down.
4 To specify reverse order, click the column, then click Descending.
5 Click OK.

Building Queries 63
Submitting Queries
Once you’ve built a query, you can submit it to the database. The
results of the query are displayed in a separate window.

You can build your entire query and then submit it. Or you can specify
some initial qualifications, submit the query, review the results, and
then revise the query to retrieve exactly the set of results you want.

To submit a query to the database


1 Choose Query>Submit Query.
OR
Click the green light icon on the application toolbar.

Saving Queries
It’s good practice to save any query that you want to use more than
once so that you don’t have to rebuild it each time. Once a query is
saved, it can be:

• loaded, then submitted

64 Building Queries
• automated by being linked to a button
• stored with the data model in the database

To save queries, you must have the Save Queries permission. You can
save a query to make it available in BI/Query. You can also save the
corresponding SQL string to make it available to other applications (see
“Exporting Queries” on page 155), provided that your query doesn’t
require manipulation of the results set (see “Ordering Query Results”
on page 58 and “Combining Queries” on page 129).

Saving a query in a results window saves the query that generated the
results. Saving in any other window saves the current query.

BI/Query saves queries with the extension .qry and stores them in the
Queries folder by default, but you can also store them elsewhere. Data
values queries are saved in the DataVals folder. (See “Creating Data
Values Query Files” on page 90.)

If the Query>Publish command is enabled and you have the


appropriate permissions, you can also publish queries to the repository
and retrieve them. Publishing queries to the repository gives you the
ability to schedule and secure them and provides an efficient way to
share your queries with others. See the BI/Broker Publishing and
Scheduling Guide for more information.

To save a query
1 Make sure you have the Save Queries permission.
2 Build a query. (You can submit the query before or after saving it.)
3 Choose Query>Save.
4 In the Save Query dialog box, specify a file name.

Building Queries 65
5 To save the query in a location other than the Queries folder, click
Export and specify the name and location of the file.
6 Click Save.

Loading Queries
You can load and submit queries that you’ve saved as well as queries
that have been stored with the data model.

To load and submit a saved query


1 With a data model open, choose Query>Load.
2 In the Load Query dialog box, select a query from the list of Saved
Queries.

66 Building Queries
3 To submit the query without first displaying it, click Submit.
OR
To display the query, click Load.

Saving Results
You can save query results to a file in order to use them again in
BI/Query or to use them in other applications, such as word processors
and spreadsheet programs.

BI/Query saves results as two separate files with the extensions .qrd and
.qrr. The .qrd file contains the results stored in text format so that other
applications can open them. (BI/Query automatically supplies the .qrd
extension when you save results.) The .qrr file stores additional

Building Queries 67
information that BI/Query needs to open the results file (such as
formats for each column and the SQL used to retrieve the results).
When you load results in BI/Query, you see only the .qrd file. If you
need to delete a results file, delete both the .qrd and .qrr files.

The results are stored on your computer so that you can manipulate
them locally instead of in the database, thereby reducing the demands
on the server.

To save results
1 In the results window, choose Results>Save As>Results.
OR
To submit results directly to a file, choose Query>Submit
Query...>To File.
2 In the Save Query Result to File dialog box, specify the name and
location of the file, then click Save.

68 Building Queries
Formatting Data

Entering Data 71
Default Format 71
Matching Display Formatting 71
Numbers 72
Dates 73
Invalid Entries 73
Converting Two-digit Years 73
Choosing a Date Range 74
Choosing a Date Range Type 74
Displaying Data 75
Formatting Numbers 76
Formatting Dates 77
Inserting and Deleting Characters 77
Substituting Values 78
Formatting Data
Data formats govern how you enter numbers, dates, and text characters You specify data
and how these are displayed in query results. For example, numbers can formats for reports
in BI/Query
be represented as 99999, 99,9999, and 99.999, and dates can be
Reports. (See the
represented as 1/14/1998, 1998.1.14, and January 14, 1998. BI/Query BI/Query Reports Guide.)
lets you specify different formats for different purposes.

The Control Panel settings on your computer determine the default


data-entry and display formats. You can change the default display
format for each attribute in a query that you build. For results windows,
the display formats specified in BI/Query take precedence over the
default database formats and Control Panel settings. You can then make
the data-entry format match the new display formats you’ve set.

Entering Data
The format in which you type dates and numbers in query
qualifications, prompts, and variables is the data-entry format.

Default Format
The default data-entry format is normally based on the Control Panel
settings on your computer. Any changes you make to these settings
take effect immediately.

To specify the default data-entry format When you set the


data-entry format
1 In Regional Settings in the Control Panel, specify a format. to match the
results display for-
mat, it applies to all attributes
Matching Display Formatting for which you’ve specified a
display format. To use the
Instead of using the default, you can set the data-entry format to match default format for an attribute,
set its format to the default.
the format that’s used to display query results. (For information on how
(See “Displaying Data” on
you can set the results display format, see “Displaying Data” on page 75.)

Formatting Data 71
page 75.) Using the results display format rather than the default data-
entry format is useful when you want to display an integer (such as
2017434411) as a phone number (201-743-4411) or when a currency
is specified as a number and you want the data to appear with the
currency symbol. (You can’t change the data-entry format for character
data types.)

Avoid using an attribute format for numbers and dates that “hides”
information. For example, with a format such as MMM/D, if you type
Sept 15, 2001 into a qualification, BI/Query inserts Sept 15, 2001 into
the SQL for the query, but displays Sep 15 in the qualification tree. If
you change the value to Sept 25, BI/Query interprets your change as
being a complete value (Sep 25, not Sept 25, 2001). The “hidden” year
is lost, and the query retrieves unnecessary or incorrect data.

BI/Query hides the year when the attribute uses a “hidden” format.

BI/Query is flexible in recognizing the data you type. You can use the
format specified in the Control Panel or a comparable one. If
BI/Query is able to interpret the format, it automatically converts it to
the default data-entry format.

To specify a data-entry format that matches the attribute format


1 Choose Tools>Preferences.
2 In the Preferences dialog box, click Attribute under Qualification
Format.
3 Click OK.

Numbers
You can type numbers (including currencies) without formatting them.
BI/Query converts them to the format you’ve specified.

72 Formatting Data
Dates
You can type dates using any format comparable to the one you’ve To ensure that
specified. For example, if the date format you’ve specified is BI/Query inter-
prets dates cor-
1/14/2001, you can type dates in the format 2001.1.14, 1.14.2001,
rectly, make sure
January 14, 2001, or even 2001 Jan 14. As long as you include the day, that you type dates using all
month, and year and BI/Query is able to unambiguously interpret the four digits of the year.
format, it converts the date to the specified format.

Invalid Entries
BI/Query alerts you when you type data in a format it can’t interpret.
To return to the entry and correct it, click Cancel in the alert window.
(If you’re not sure what format to use, check the Regional Settings in
your Control Panel.) If you want BI/Query to accept the entry you
typed, click Add { }; your entry appears within the brackets. When
you submit a query, BI/Query enters the entry as straight text into the
SQL string. This is an escape mechanism designed for users with
advanced knowledge of SQL database access.

Converting Two-digit Years


When you type a two-digit year or import a data source that contains
two-digit years, BI/Query converts them to four-digit years.

Formatting Data 73
Choosing a Date Range

If you change the To enable BI/Query to convert two-digit years correctly, you must
date window after first specify the start day for a 99-year range of dates in your data. For
typing two-digit
instance, if you know that you won’t need to enter dates earlier than
years, the new
date window doesn’t apply to 1930, you can specify a range that begins with 1930. BI/Query
the dates you’ve already automatically ends the range with 2029. For this range, whenever you
entered. enter or import a two-digit number greater than or equal to 30 (from
30 to 99), BI/Query converts it to a four-digit number that begins with
19. For instance, when you type 45, it’s converted to 1945. Whenever
you enter or import a two-digit number less than or equal to 29 (from
00 to 29), BI/Query converts it to a four-digit number that begins with
20. For instance, when you type 15, it’s converted to 2015.

Choosing a Date Range Type

Once you’ve selected a range, then you need to establish whether it’s a
sliding or fixed range.

The start and end years of a sliding range are incremented by one each
time the current year changes. For example, a range of 1930 to 2029
chosen in the year 1999 becomes, in the year 2000, a range of 1931 to
2030. If in the year 2000 you will no longer need to enter the two-digit
year 30 as 1930 and will want instead to enter it as 2030, you can use
the sliding range.

The start and end years of fixed ranges don’t change. If, for example,
you choose a range of 1930 to 2029 as a fixed range, BI/Query will
always accept the two-digit year 30 as 1930 and the two-digit year 29
as 2029, no matter in what year you enter them.

The type of date range you specify in one product applies to all
Hummingbird Business Intelligence products.

To convert two-digit years


1 Choose Tools>Date Entry.
2 In the Date Entry dialog box, type a start year for the date window.

74 Formatting Data
3 Click Sliding or Fixed.
4 Click OK.

Displaying Data
When results are returned from the database, the format in which To view an
they’re displayed (the display format) may not be how you want them attribute’s default
display format,
represented in the results window. BI/Query offers a wide range of click the question
display formats for formatting columns of data. You can change the mark beside the attribute in
default display format for each attribute in an attribute window, and the attribute window.
save those changes if you have permission to save the data model. (For
information on saving a data model, see the BI/Query Data Models
Guide.) Or, after results are returned, you can specify a display format
from the results window. If you save the results set, the formats you
specify in the results window are saved with it.

You may need to change the display format for a particular set of
results. Whether you select a single cell or an entire column, the
formatting is applied to all the results in the column.

To specify a display format


1 In an attribute window, click the question mark beside an attribute.
In the Attribute dialog box, click Edit.
OR
In a results window, select one or more cells or column headings,
then choose Results>Format.
2 In the Specify Display Format dialog box, specify a format. (For
instructions, see the sections below.)

Formatting Data 75
3 Click OK.

Formatting Numbers
You can select from a number of predefined formats for numeric data.
You can also modify one of these formats by including, for example, a
dollar sign or percent symbol as a prefix or suffix. You can also
highlight negative values in red, hide zero values, and display values in
exponent notation.

To format numbers
1 In the Specify Display Format dialog box, click Numeric.

2 Select a format from the Predefined Formats list.


3 To modify the format, use the available text and check boxes.
4 Click OK.

76 Formatting Data
Formatting Dates
You can select from a number of predefined formats for dates, and you
can include the time.

To format dates
1 In the Specify Display Format dialog box, click Date.

2 Select a format from the Predefined Formats list.


3 To include the time, click Show Time.
4 Click OK.

Inserting and Deleting Characters


By inserting and deleting characters in character, number, and date
strings, you can adjust data formats to include punctuation, include
missing information, and exclude unwanted information. BI/Query
recognizes special characters that tell it to include or exclude characters
in the original data. For example, you can specify that telephone
numbers stored in the database in the format 6135484355x15 be
displayed as (613) 548-4355 Ext. #15 by typing them in the format
(###) ###-#### Ext. \#*.

To insert and delete characters


1 In the Specify Display Format dialog box, click String.

Formatting Data 77
2 Type a format into the Format String text box using the following
special characters:
# inserts a character from the original data
_ suppresses a character in the original data
* inserts the remaining characters in the original data
\ inserts the next character(s) you type; use it to include one of the
special characters (for example, to insert the # character, type \#)
3 Click OK.

Substituting Values
You can substitute values in a results column to highlight trends, focus
on general information rather than specific details, and flag exceptions.
For example, it may be useful to assign a single value (the word
Unsatisfactory) to a range of values (all sales below a certain amount) so
that you can easily identify areas that require further attention. You can
also apply a color for emphasis in any corresponding reports. (The color
is displayed only in standard reports, not reports created using
BI/Query Reports.)

To substitute values in results


1 In the Specify Display Format dialog box, click Computed String.

78 Formatting Data
2 Select an operator from the list beside the Comparison Value text To insert a row,
box. place the cursor in
the row below
3 Type the value you want to replace into the Comparison Value text which you want
box. to insert the row, then click
4 To change the value, type a new value into the corresponding Insert Row. To delete a row
Replacement Value text box. you’ve specified, choose the
first (blank) item from that
5 To specify more than five sets of values, use the scroll bar to display row’s operator list.
more blank rows.
6 To specify a color for the new value in the corresponding standard
report, click the color button and specify a color.
7 Click OK.

Formatting Data 79
Data Values Files, Prompts, and Variables

Data Values Files 83 Specifying Attributes and Operators 110


Naming and Storing Data Values Files 85 Naming the Attribute and Operator 110
Creating Data Values Results Files 86 Using Placeholders 111
In BI/Query 87 Including Functions 113
Using a Text Editor or Spreadsheet Program 89 Including Variables 114
Creating Data Values Query Files 90 Including Prompts 115
Using Data Values Files to Alias Data 93 Importing Variables from a File 116
Prompts 96 Using Variables to Supply User Names 117
Naming and Storing Prompts 97
Creating Single Prompts 97
Group Prompts 98
Creating the Prompts 99
Creating the Title 100
Testing the Prompt 100
Conditional Prompts 101
Creating the Group Prompt 102
Creating the Data Values Query File 103
Testing the Conditional Prompt 104
Importing Prompts 106
Variables 107
Creating Variables 108
Data Values Files,
Prompts, and Variables
One of the goals of building a query is that it will limit what it retrieves
from the database to the information that interests you. One way to
limit what it retrieves is by qualifying attributes with data values. (See
“Qualifying Queries” on page 32.) You can supply data values to
accomplish that goal in any of the following ways.

Before you submit the query, you can insert one or more data values
into a qualification, either by typing them or by choosing them from a
list. Lists of data values are provided by data values files.

You can also build a query that you qualify using one or more prompts,
and then save the query for later use. Whenever you submit such a
query, you’re prompted to insert the data values to be used in the
qualification. Depending on what values you choose to insert when
prompted, the same query can be used to retrieve different subsets of
data. You can type data values in response to a prompt, but prompts
can also have data values lists associated with them. And you can
combine data values files and prompts so that you can insert values into
one prompt that are based on values you inserted into another.

You can also build a query that you qualify using variables and then save
the query for later use. Whenever you submit such a query, the variable
runs automatically, performs pre-defined operations, and supplies the
resulting data value(s) for the qualification. You can include prompts in
variables and you can include one variable in another.

Data Values Files


Data values files are lists of data values from you can use to restrict
query results. Selecting data values from a list is a more accurate and

Data Values Files, Prompts, and Variables 83


efficient way to insert values than typing them. (See “Data Values and
Data Values Lists” on page 35.)

There are two kinds of data values files. Data values query files query the
database and retrieve a subset of values to create the list; data values
results files display a stored set of values. Data values query files provide
the most accurate lists; the first time you use them in a session, they
query the database to supply the values. Data values results files are
produced by storing the results of a query or, sometimes, produced
manually. BI/Query doesn’t update the lists corresponding to them.
Results files reduce the load on the database server because they
eliminate the need to query the database.

A data values file contains a subset of all of the possible values in the
database. These values appear as a list when you click the Data Values
icon (see “Data Values Icon” on page 34). If no data values file is
available for a particular attribute, when you click the Data Values icon
and choose Data Values, BI/Query runs the default query and retrieves
all of the values.

The administrator, however, can disable access to the default query.

The Data Values dialog box displays no values when the administrator has disabled the
default data values query.

Disabling it is recommended when loading all the values in the database


uses network resources inefficiently — for example, when an attribute
has a large number of values or when those values are simply numbers
and dates. (For more information, see the BI/Query Data Models Guide.

84 Data Values Files, Prompts, and Variables


For information on qualifying an attribute with data values, see “Data
Values and Data Values Lists” on page 35.)

How data values files are named determines which file BI/Query uses
and whether it’s used in a qualification or a prompt.

Naming and Storing Data Values Files


Data values query and results files require special naming conventions.
When they supply values to be used in a prompt, they use the prompt
name. (See “Naming and Storing Prompts” on page 97) When they’re
used in both qualifications and prompts, they use the format data object
name.attribute name where data object name and attribute name are the names
used in the data model (not the names of the table and column in the
database). For instance, for a data object called Retailers with an
attribute called country, a data values file would be called
Retailers.country. Be sure to use the case used in the attribute or prompt
name.

Data values query and results files are stored in the DataVals folder. The
file names you give these files determine the order in which BI/Query
selects the files in the DataVals folder as well as whether the
corresponding data values are available in a qualification or in a prompt.
The following table shows the order in which BI/Query uses data
values files, their names, and where they’re used.

Data Values File Descriptive Name Available In

Results file named after the prompt name Prompt dialog


corresponding prompt box

Query file named after the prompt name Prompt dialog


corresponding prompt box

Data Values Files, Prompts, and Variables 85


Data Values File Descriptive Name Available In

Results file named after the data object Qualification


data object and attribute name.attribute tree, prompt
used in the query name dialog box

Query file named after the data object Qualification


data object and attribute name.attribute tree, prompt
used in the query name dialog box

If none of these data values files is found, BI/Query uses a default query to supply the
data values in the database (unless the administrator has disabled the default query).

When you click the data values icon in a prompt dialog box in order to
display a list of data values that can be used in the prompt, BI/Query
checks to see if there’s a data values file with the same name as the
prompt. If there is, BI/Query uses it; otherwise, it checks to see if there
is a data values file named after the data object and attribute used in the
query. If there is, BI/Query uses it.

If BI/Query doesn’t find a data values file, and if data values for an
attribute haven’t been disabled, BI/Query runs a default query that
retrieves all the unique values in the database for the attribute and
displays the results in a list.

Creating Data Values Results Files


A data values results file stores a set of data values for an attribute. It
allows you to access a data values list without querying the database
each time you need it. A data values results file can be linked to a
prompt or an attribute so that its contents are available in a data values
list in a qualification tree or in a prompt dialog box. When you click
the data values icon, the values stored in the results file are displayed.

86 Data Values Files, Prompts, and Variables


Qualification tree

Qualification prompt dialog box

If data values haven’t been disabled for an attribute, you can access all Creating data val-
the data values in the database instead of just those in the data values ues results files is
useful when the
results file. Select more from the data values list, then in the Data Values data changes
dialog box, click Load All. infrequently. If a file needs to
be updated often, create a data
You can create a data values results file from results you’ve retrieved in values query file instead. (See
BI/Query as well as by using a text editor or spreadsheet program. “Creating Data Values Query
Files” on page 90.)

In BI/Query

When you create a data values results file in BI/Query, be sure to


eliminate duplicate values from your results. You can select the
attribute to retrieve all of the values in the database for your results file,
or you can qualify the attribute to retrieve only specific values.

Data Values Files, Prompts, and Variables 87


This query returns a list of cities in the state of New York, sorted alphabetically.

To create a data values results file in BI/Query


1 In an attribute window, click an attribute. (You can select only one
attribute for a data values results file.)
2 To sort the results, click the Sort box, if you want to sort the results,
then apply any other restrictions you want.
3 Choose Query>Modifiers>Distinct to eliminate duplicate values.
4 Submit the query.
5 In the results window, choose Results>Save As>Data Values.
6 In the Data Values dialog box, name the file. (See “Naming and
Storing Data Values Files” on page 85.)

88 Data Values Files, Prompts, and Variables


7 Click Save.

Using a Text Editor or Spreadsheet Program

You can use any text editor or spreadsheet program to create a data
values results file that contains a set of customized data values. To do so,
create a data values results file first; it will serve as a template for the
customized data values. This is necessary because BI/Query stores data
values results files in two separate files: the .qrd file, which stores results
in text format, and the .qrr file, which stores additional information that
the application needs to read the text file. Without the .qrr file,
BI/Query can’t open the .qrd file. Once you create these files, you’ll
replace the data values in the .qrd file with the customized data values.

When you type values into the text editor or spreadsheet program, type
them in the order and case you want them to appear in BI/Query,
pressing Enter after each value.

To create a data values results file using a text editor


1 In an attribute window, click an attribute. (You can select only one
attribute for a data values results file.)
2 To sort the results, click the Sort box, then apply any other
restrictions you want.
3 Choose Query>Modifiers>Distinct to eliminate duplicate values.
4 Choose Query>Submit to submit the query.

Data Values Files, Prompts, and Variables 89


5 In the results window, choose Results>Options.
6 Under Separators in the Results Options dialog box, specify <CR>
in the Record text box and <None> in the End of File text box.

7 Click OK.
8 In the results window, choose Results>Save As>Data Values.
9 In the Data Values dialog box, name the file. (See “Naming and
Storing Data Values Files” on page 85.)
10 Click OK.
11 In a text editor or spreadsheet program, open the .qrd file you
created, modify it, and save it under the same name.
Or, type a list of values in a new document file, pressing Enter after
each one, then save the file using the same path and file name as the
.qrd file.
12 To test the file in BI/Query, click the attribute used to create the
original results, click its Qualify box, then click the data values icon
in the qualification tree.

Creating Data Values Query Files


A data values query is a query that BI/Query submits when you click
the Data Values icon and select Data Values. The data values query
retrieves data values for an attribute from the database. Then it displays
them in the Data Values dialog box so that you can select those you
want to insert into a prompt or qualification.

90 Data Values Files, Prompts, and Variables


A data values query file can be linked to a prompt or an attribute so that Queries that
the query results are available in a data values list in a qualification tree require BI/Query
to manipulate the
or in a qualification prompt dialog box. results can’t be
used as data values query files.
(See “Ordering Query
Results” on page 58, “Nar-
rowing the Range of Results”
Qualification tree
on page 128, and “Combin-
ing Queries” on page 129.)

Qualification prompt
dialog box

If data values haven’t been disabled for an attribute, you can access all
the data values in the database instead of just those returned by the data
values query by clicking Load All.

Just as with data values results files, when you create a data values query
file, you’ll want to eliminate duplicate values from your results. You
can select just the attribute, in order to retrieve all of the values in the
database for that attribute, or you can qualify the attribute to retrieve
only specific values.

Data Values Files, Prompts, and Variables 91


This query returns a list of staff titles, sorted alphabetically.

To create a data values query file


1 In an attribute window, click an attribute.
2 Click its Sort box to sort the results alphabetically, then apply any
other restrictions you want.
3 Choose Query>Modifiers>Distinct to eliminate duplicate values.
4 Choose Query>Save.
5 In the Save Query dialog box, click Data Values Queries, then
specify a name for the file. (See “Naming and Storing Data Values
Files” on page 85.)

92 Data Values Files, Prompts, and Variables


6 Click Save.

Using Data Values Files to Alias Data


Data aliasing allows users to select from a list of common-language
names for data values while BI/Query inserts the corresponding actual
values into the query.

To set up data aliasing, you create a data values results file or data values
query file that contains two columns; in the first column are the actual
values, in the second are the aliases. Only the data in the second
column is displayed in the list of data values. Instead of selecting a value
for a qualification that may be difficult to understand or remember,
such as a staff person’s ID number, you’ll be able to select a more
meaningful value, such as the person’s last name. You select the name
from a list of data values and BI/Query inserts the ID number into the
qualification edit box for the query.

When you qualify the ID# attribute, click the data values icon in the
qualification tree, BI/Query displays staff last names as a list.

Data Values Files, Prompts, and Variables 93


When you select a name from the list, BI/Query inserts the
corresponding ID number into the qualification tree.

ID for Peterson

To create a data values file that aliases data


1 In an attribute window, click an attribute that represents the values
you want to alias.
2 Click a second attribute that represents the value you want to be
displayed in the data values list, then, if you want to sort it, click its
Sort box.

94 Data Values Files, Prompts, and Variables


3 Save the query as a data values query file. (See “Creating Data
Values Query Files” on page 90.)
OR
Submit the query and save the results as a data values results file.
(See “Naming and Storing Data Values Files” on page 85.)

4 Name the file after the first attribute (for example, Staff.ID #).

Data Values Files, Prompts, and Variables 95


Prompts
A prompt is a request to insert a value into a qualification when you
submit a query. You can qualify a query with a prompt so that each
time you submit the query, you’re prompted to specify the
qualification value you want to use. (See “Qualifying Queries” on
page 32.) You can also include a prompt in a variable in order to
qualify a variable without inserting a value each time the variable is
used. (See “Including Prompts” on page 115.) And you can qualify a
data object or actual relationship with a prompt in order to restrict
users’ queries to specific information in a table. (See the BI/Query Data
Models Guide.)

For tables that contain a large number of rows, prompts improve query
performance and prevent users from submitting queries that retrieve
more data than they need. For example, regional sales managers may
need sales information only for countries in their region. When they
submit queries against the table containing countries, the queries
prompt them to specify the countries they want.

You can submit queries using single prompts, group prompts, which
are made up of a number of individual prompts, and conditional
prompts, in which the data values returned for one prompt are based on
the value you specify for another.

96 Data Values Files, Prompts, and Variables


Naming and Storing Prompts
Single prompts can have any name, although they’re usually named
after the attribute they qualify. (For example, if you create a prompt
that qualifies the City attribute, the prompt can be named City.) Group
and conditional prompts have special naming conventions. (See
“Group Prompts” on page 98 and “Conditional Prompts” on
page 101.) BI/Query stores prompts in a single Prompts file in the
Queries folder.

You can type data values into a prompt or insert them from a data
values list. (See “Data Values and Data Values Lists” on page 35.)

Creating Single Prompts


A single prompt prompts you for one or more values for an attribute.

To create a single prompt


1 Choose Edit>Prompts.
2 In the Prompts dialog box, click New.

Data Values Files, Prompts, and Variables 97


3 In the Edit Prompts dialog box, type a prompt name into the
Prompt ID text box.
4 Type into the Prompt String text box a phrase that describes the
data value or values wanted.

5 Click OK.

Group Prompts
A group prompt is made up of two or more single prompts. All the
prompts can have the same group name and be displayed together in
one or more dialog boxes depending on the number of prompts in the
group. For example, a group prompt can be made up of prompts for
the Country and City attributes so that a query that qualifies those
attributes prompts you to select first a country, then one or more cities.

98 Data Values Files, Prompts, and Variables


A group prompt can display up to five prompts in one dialog box. If it
contains more than five prompts, the first dialog box displays the first
five prompts, the second displays the next five, and so on. A query can
contain more than one group prompt.

When queries are qualified with more than one prompt, grouping
them in a dialog box allows users to see all the prompts at once and
reduces the number of steps in the query. It also relates one prompt to
another. (See “Conditional Prompts” on page 101.)

Creating the Prompts

An exclamation mark is used to identify each prompt in a group


prompt. In order to keep related prompts together, it’s good practice to
provide a group name that precedes the exclamation mark. For
example, in the prompt Retailer!City, the group name is Retailer! and
the prompt name is City. If you don’t specify an order for the prompts,
they’re executed in alphabetical order — for example, Retailer!City is
run before Retailer!Country. If you want the prompts to appear in a
particular order, specify the order in their names. For example, to
ensure that the country prompt is run before the city prompt, use the
names Retailer!2City and Retailer!1Country.

To create the prompts for a group prompt


1 Create at least two single prompts with a group name. (See
“Creating Single Prompts” on page 97.)

Data Values Files, Prompts, and Variables 99


Creating the Title

The dialog box that displays a group prompt displays the default title
Please Enter Qualification Values. You can create your own title for this
dialog box by creating a prompt that begins a the group name, two
exclamation marks, and Title (for example, Retailer!!Title). You must
use the word Title with a capital T. The prompt string you type
becomes the title.

To create the title for a group prompt


1 Choose Edit>Prompts.
2 In the Prompts dialog box, click Edit.
3 In the Edit Prompt dialog box, type the name of a prompt into the
Prompt ID text box.

4 In the Prompt String text box, type a title for the prompt.
5 Click OK.

Testing the Prompt

Before distributing a group prompt, it’s useful to test it to ensure that it


works properly. When you submit the query, the group prompt dialog
box displays the prompts in the order and with the title you specified.

To test a group prompt


1 In an attribute window, click the attributes you want.
2 For each attribute, click its Qualify box, choose Edit>Prompts,
then specify a prompt.

100 Data Values Files, Prompts, and Variables


3 Submit the query.
4 In the group prompt dialog box, specify a value in the first text box.
(Type it or use the data values icon to select a value from a list.)

Data values icon

5 Specify a value in the second text box.


6 Click OK.

Conditional Prompts
Conditional prompts are group prompts in which the data values available
for one prompt are determined by the value specified for another. For
example, a prompt for cities provides only those cities located in the
country you specify for the country prompt. You create a conditional

Data Values Files, Prompts, and Variables 101


prompt by creating a group prompt, then creating a data values query
file that retrieves data values based on the value specified for one of the
prompts.

When you select data values from a list instead of typing them into a
prompt, conditional prompts eliminate inappropriate values from the
list and make it easier for you to find the appropriate values.
Conditional prompts are also useful in a data model that doesn’t allow
users to build their own queries, because they provide a means of
drilling down to obtain increasingly detailed information. (See the
BI/Query Data Models Guide.)

Displays only cities in USA

Creating the Group Prompt

Make sure your group prompt prompts you in the order you want. For
example, to ensure that you’re prompted first for a country, then for a
city, name the first prompt Retailer!1Country and the second prompt
Retailer!2City.

To create the group prompt


1 Create a group prompt with a group name. (See “Group Prompts”
on page 98 and “Creating Single Prompts” on page 97.)

102 Data Values Files, Prompts, and Variables


Creating the Data Values Query File

Now you create a data values query file that returns unique values for
the attribute that corresponds to the second prompt. Be sure to
eliminate duplicate values from your results.

To create the data values query file


1 In an attribute window, click an attribute that corresponds to the
second prompt.
2 If you want to sort the attribute, click its Sort box, then choose
Query> Modifiers>Distinct to eliminate duplicates.
3 Qualify the attribute that corresponds to the first prompt with the
first prompt.
4 Apply an operator. (See “Restricting Qualifications with
Operators” on page 42.)

This query retrieves a list of cities for the country specified for the Retailer!1Country
prompt.

5 Save the query as a data values query file using the name of the
second prompt in the group prompt. (See “Creating Data Values
Query Files” on page 90.)

Data Values Files, Prompts, and Variables 103


Testing the Conditional Prompt

Before distributing a conditional prompt, it’s good practice to test it to


ensure that it works properly.

To test a conditional prompt


1 In an attribute window, click the attributes you want.
2 Qualify the attribute that corresponds to the first prompt with the
first prompt.
3 Qualify the attribute that corresponds to the second prompt with
the second prompt.
4 Apply an operator. (See “Restricting Qualifications with
Operators” on page 42.)

The Country attribute is qualified by the Retailer!1Country prompt, and the City
attribute is qualified by the Retailer!2City prompt.

5 Submit the query.


6 In the group prompt dialog box, type a value into the first text box.
OR
If data values haven’t been disabled for the attribute, click the data
values icon and select a value from the list.

104 Data Values Files, Prompts, and Variables


7 Click in the second text box.
8 Click the data values icon that appears, then click Data Values.

Clicking Data Values submits the data values query file (Retailer!2City) and displays
the results in the Data Values dialog box.

9 In the Data Values dialog box, select the value(s) you want.
(Depending on the operator you applied to the qualification, you
can select one or more values.)

10 Click Insert.

Data Values Files, Prompts, and Variables 105


11 In the group prompt dialog box, click OK.

Importing Prompts
You can distribute prompts by copying and renaming your Prompts file
(located in the Queries folder); other users can then import the prompts
contained in this file. You can also import prompts stored in someone
else’s Prompts file.

To import prompts
1 Choose Edit>Prompts.
2 In the Prompts dialog box, click Import.
3 In the Select Import File dialog box, select the file that contains the
prompts you want to import, then click Open.

4 In the Import Prompts dialog box, select the prompts you want
under Prompts to Import, then click Import.

106 Data Values Files, Prompts, and Variables


5 Click Done.
6 In the Prompts dialog box, click Done.

Variables
A variable (or automatic variable) is a predefined operation that can be
used to qualify an attribute. (See “Variables” on page 38.) The
operation is performed when you submit the query and the results are
then used to qualify the query. Variables can also be used to qualify data
objects in a data model. (See the BI/Query Data Models Guide.)

Variables can carry out a variety of operations. In their simplest form,


they can retrieve values in the database so you don’t have to specify
them in queries. For example, when you need information about
retailers in a particular country, you can use a variable to determine the
states or provinces that are included in that country, rather than specify
each state or province yourself.

Variables can also perform calculations based on database functions to


work out date, time, and other values. For example, you can use a
variable to retrieve retailer sales that were placed today, before today,
and so on. The variable supplies what today’s date is, and BI/Query
returns the corresponding results.

Data Values Files, Prompts, and Variables 107


Variables are especially useful for queries that are run on a regular basis
or are scheduled to run at specific intervals because they can
automatically supply data values for the time when they are run.

A variable can contain attributes, operators, values in the database,


calculations, functions, subqueries, prompts, other variables, or stored
procedures (anything that’s valid in an SQL WHERE clause). Variables
take the work out of formulating potentially complex queries.

Variables are stored in the Prompts file in the Queries folder and
therefore must have names that are different from those given to
prompts. You can import variables stored in another user’s Prompts
file. (See “Importing Variables from a File” on page 116.)

Creating Variables
You can test that When you submit a query qualified with a variable, the variable is
an expression executed as a complete expression — that is, the variable is substituted
returns the results
you want by creat-
for the entire qualification, including the attribute and operator. As a
ing a calculated attribute that result, a variable must contain information about what attribute to
uses the same expression. Use qualify and what operator to use, as well as the operation to be
the attribute in a query, then performed.
verify the results. (For infor-
mation on creating calculated
attributes, see “Creating
Attributes That Perform Cal-
culations” on page 55.)
When the query is submitted, the variable Customers Exceeding Credit is substituted for
the entire qualification shown above. Customers Exceeding Credit performs the
operation retailers.receivable >retailers.credit, substituting “retailers.receivable” for the
attribute Credit Limit and “>” for the operator “=”.

A stored procedure may already contain attribute and operator


information; in all other cases, you’ll need to provide it when you
create the variable.

You can add to a variable any value, calculation, function, subquery, or


stored procedure that’s valid in an SQL WHERE clause and supported
by the DBMS. The syntax for variable expressions depends on the
DBMS; the examples provided in this chapter are based on ODBC.

108 Data Values Files, Prompts, and Variables


To create a variable
1 Choose Edit>Variables.
2 In the Variables dialog box, click New.

3 In the Edit Automatic Variable dialog box, type a name and


description into the Name and Description text boxes.

Attribute placeholder Specific operator Determines today’s date

This variable determines today’s date. You can use it to qualify a query for sales at
the end of a quarter rather than qualify the query with a specific date.

Data Values Files, Prompts, and Variables 109


4 Specify the expression you want the variable to perform. (See the
instructions below.)
5 Click OK.

Specifying Attributes and Operators


There are two ways to provide attribute and operator information in a
variable. You can create a variable that names an attribute and operator.
Or you can create a variable that uses placeholders for them.
Instructions for each are provided below.

To specify an attribute and operator


1 In the Edit Automatic Variable dialog box, select a data object from
the Table/Attributes list.
2 To specify an attribute, select an attribute from the list under
Table/Attributes, then click Insert Selection. (See “Naming the
Attribute and Operator” on page 110.)
OR
To specify a placeholder for an attribute, with the cursor in the
Expression text box, click ^Attribute^. (See “Using Placeholders”
on page 111.)
3 To specify an operator, type it into the expression.
OR
To specify a placeholder for an operator, with the cursor in the
Expression text box, click ^Operator^.
4 Click OK.

Naming the Attribute and Operator

A variable that names an attribute and operator will always qualify that
attribute using that operator, even if you insert it into the qualification
of a different attribute in the query. For example, suppose that in a
Retailers data object, you create a query by selecting Name and Credit
Limit. You decide to qualify the query with the Customers Exceeding
Credit Limit variable. The variable performs the operation

110 Data Values Files, Prompts, and Variables


retailers.receivable>retailers.credit. In other words, it qualifies the
Current Receivable (retailers.receivable) attribute by restricting it to
those retailers whose receivables are greater than their credit limits
(>retailers.credit). You can qualify Name, Credit Limit, or any
attribute you like with this variable, and the result will be the same
because the variable will always qualify the Current Receivable
attribute using the “>” operator.

retailers.receivable>retailers.credit

retailers.receivable>retailers.credit

retailers.receivable>retailers.credit
For any attribute you qualify
with the Customers Exceeding
Credit variable, the results
are the same, because it
substitutes the Current
Receivable (retailers.
receivable) attribute and
the “>” operator.

Using Placeholders

A variable that includes placeholders for the attribute and the operator
always qualifies the attribute into which it is inserted and uses the
operator you specify in the qualification tree. (When you submit a

Data Values Files, Prompts, and Variables 111


query qualified by such a variable, the ^Attribute^ placeholder is
replaced with the current attribute and the ^Operator^ placeholder is
replaced with the current operator.)

For example, you could replace the Customers Exceeding Credit


variable (retailers.receivable>retailers.credit) in the example above with
a variable that substitutes placeholders for the attribute and operator
(^Attribute^ ^Operator^ retailers.credit). If you select the Name and
Credit Limit attributes, then qualify Current Receivable with the
placeholder version of the variable and choose the “>” operator, the
results are the same as those in the earlier example.

^Attribute^ ^Operator^ retailers.credit

If you use the same placeholder variable to qualify a different attribute,


however, you’ll get different results. If, for instance, you qualify the
Invoice Amount attribute with the placeholder variable, the variable
finds the Name and Credit Limit of those retailers who are being
invoiced for amounts greater than their credit limits.

112 Data Values Files, Prompts, and Variables


^Attribute^ ^Operator^ retailers.credit

You can use placeholders to create variables that return different results
depending on the attribute qualified and the operator used.

You include a placeholder in a variable you are creating or editing by


clicking ^Attribute^ or ^Operator^ in the Edit Automatic Variable
dialog box.

Using placeholders also allows you to create a variable that calculates


today’s date; you can apply the variable to any date attribute in the data
model. The operator you specify in the qualification determines how
the attribute is compared to today’s date — before (<), after (>), equal
to (=), and so on. No matter what attribute or operator you use in the
qualification tree, the query returns results based on today’s date. For
example, if you specify the Greater Than (>) operator, the query
returns results for all dates greater than today’s date.

Including Functions
Variables often include functions that perform some type of calculation.
Using the DBMS function for the current date, for example, a variable

Data Values Files, Prompts, and Variables 113


can determine the date for the beginning of the month to allow you to
find all retailer sales received since that date.

^Attribute^ ^Operator^ {fn now()}


- {fn dayofmonth({fn now()})}

To include a function in a variable


You can use most 1 In the Edit Automatic Variable dialog box, click Function.
scalar functions
2 In the Insert Function dialog box, select a function.
available in your
DBMS even if
they don’t appear in the
Other Functions list. Type the
function into the Expression
text box. (Check your DBMS
documentation for the correct
format.)

A list of built-in SQL functions appears under Functions. For certain DBMS types, a
list of scalar functions appears under Other Functions.

3 Click Insert.
4 To include the value to which you want the function to be applied,
edit the expression.

Including Variables
You can use variables as building blocks for more complex variables.

^Attribute^^Operator^ <<Today>> - 1

The Today variable determines today’s date and allows you to create a variable that
determines yesterday’s date.

To include a variable in a variable


1 In the Edit Automatic Variable dialog box, with the cursor in the
Expression text box, click Variable.

114 Data Values Files, Prompts, and Variables


2 In the Variables dialog box, select a variable, then click Insert
Variable.

Including Prompts
When you need to qualify a variable but you don’t want to restrict it to
a specific value, you can include a prompt so that you can insert a value
each time the variable is used. (For more information on prompts, see
“Prompts” on page 96.)

{fn week(^Attribute^)} ^Operator^


<<weekofyear!1week>>AND
{fn year(^Attribute^)} ^Operator^
<<weekofyear!2year>>

This variable includes the weekofyear! group prompt, which prompts you to specify first
the week you want, then the year. The variable returns results based on the week and
year you specify.

To include a prompt in a variable


1 In the Edit Automatic Variable dialog box, with the cursor in the
Expression text box, click Prompt.
2 In the Prompts dialog box, select a prompt, then click Insert Prompt.

Data Values Files, Prompts, and Variables 115


Importing Variables from a File
When you want to use variables created by another user, you can
import them from that user’s Prompts file.

To import variables from a file

When other users 1 Choose Edit>Variables.


want to use vari- OR
ables that you’ve
created, make a If you’re qualifying a query, with the cursor in the qualification text
copy of your Prompts file and box, click the data values icon, then select Variables from the list.
rename it to avoid overwrit- 2 In the Variables dialog box, click Import.
ing other users’ files. Then
distribute your file using the 3 In the Select Import File dialog box, open the Prompts file
corporate server, e-mail, or containing the variables you want.
Intranet.

4 In the Import Variables dialog box, select the variable(s) you want
under Variables to Import, then click Import>>.

116 Data Values Files, Prompts, and Variables


5 Click Done.

Using Variables to Supply User Names


Two predefined variables, DBUserID and BIUserID, are available in
BI/Query Admin. You can use these variables to customize results for
individual users without creating queries for each user.

The DBUserID variable supplies the database user name for the user Users must be
currently logged in to the database. Similarly, the BIUserID variable logged on to
BI/Broker when
supplies the BI/Broker user name for the user currently logged on to
submitting que-
BI/Broker. (See BI/Broker Users Guide.) ries that execute the BIUser-
ID variable. Otherwise, the
The creator of your data model can include a data object that associates variable can’t supply the user
data with one of these user names. Then you can qualify queries with name. This is true even
the user name variable to ensure that only the data associated with that though the user is submitting
a local copy of the query that
user is returned to that user. (For information on how to associate data would not otherwise require
in your database with a database user name or a BI/Broker user name, logging in to BI/Broker.
see the BI/Query Creating Data Models guide.)

You can use the DBUserID or BIUserID variable to qualify a query so


that it retrieves results customized for you. If you distribute that query
to other users, it retrieves results customized for each of them.

Data Values Files, Prompts, and Variables 117


To qualify a query using a user name variable
1 In an attribute window, click the Qualify box for an attribute.
2 With the cursor in the qualification text box, click the data values
icon, then select Variables from the list.
3 In the Variables dialog box, select DBUserID or BIUserID.
4 Click Insert Variable.
5 Click Done.

118 Data Values Files, Prompts, and Variables


Building Advanced Queries

Qualifying One Attribute with Another 121


Qualifying an Attribute with a Subquery 122
Modifying the SQL 125
Modifying a Query for Selected Results 126
Narrowing the Range of Results 128
Combining Queries 129
Appending One Results Set to Another 130
Joining One Column to Another 132
Understanding Which Columns to Join 136
Editing Combined Queries 136
Using the Super Query window 137
Editing a Component Query 138
Editing an Operation 139
Correcting Errors 140
Common Errors and Their Solutions 141
Creating Dynamic Relationships 142
Building Queries with a Circular Path 144
With a Correlation 145
Without a Correlation 149
Building Advanced
Queries
If you are an experienced user with an in-depth understanding of the
database, of querying, and of your organization’s business rules,
BI/Query offers additional opportunities to build custom queries in a
variety of ways. You can qualify an attribute with another attribute or
with a subquery. If you know SQL (Structured Query Language), you
can modify a query by modifying the SQL on which it’s based. You
can drill down on selected results to retrieve more detailed data and
narrow the range of results to focus on just the data you need. You can
combine queries by appending the rows or joining the columns of one
results set to another. And you can edit the combined queries you’ve
created. You can create relationships on the fly to use two previously
unrelated data objects in a query. And you can build complex queries
with a circular path.

Qualifying One Attribute with Another


BI/Query allows you to build sophisticated queries in which one
attribute qualifies another attribute. For example, a Current Receivable
attribute can be qualified by a Credit Limit attribute to retrieve only
retailers whose current receivables exceed their credit limits. When you
qualify one attribute with another, you must specify the database name
for the second attribute.

To qualify one attribute with another


1 In an attribute window, click the Qualify box for an attribute.
2 With the cursor in the text box of the qualification tree, choose
Edit>Insert DB Name.
3 In the Insert DB Name dialog box, select a data object and
attribute.

Building Advanced Queries 121


This query returns a list of retailers along with their current receivables and credit
limits. The Sort box indicates that the list will be sorted alphabetically by name. The
Current Receivable attribute is qualified by Credit Limit to retrieve only retailers
whose current receivables exceed their credit limits.

4 Click Insert Name.


5 Choose Query>Submit or save the query for later submission (see
“Saving Queries” on page 64).

Qualifying an Attribute with a Subquery


You can access your data in more dynamic ways by qualifying a query
with a nested query statement, or subquery. A subquery returns values
for a single attribute.

Let’s say you want to retrieve information about retailers with the
highest credit limit. You’re aware that the highest credit limit allowed
for your retailers changes from time to time. You build and save a

122 Building Advanced Queries


query that includes the Credit Limit attribute with the MAXIMUM
function applied to it. Then when you build other queries, you insert
that query as a subquery into a qualification, to obtain results based on
the maximum credit limit. When you submit such a query, BI/Query
submits the subquery first, then uses the results to qualify the query. By
qualifying with a subquery, you’re assured of always using the
maximum value in the database at the time you submit the query.

To qualify a query with a subquery, you need to create the subquery


first. A subquery can qualify any attribute, but it must qualify only one
attribute. It doesn’t have to qualify the attribute on which it’s based,
but it must have the same data type.

To qualify an attribute with a subquery


1 To create the subquery, in an attribute window, click an attribute.
2 Apply a function or qualification, then choose Query>Save.

3 To qualify a query with the subquery, in an attribute window, click


the Qualify box for an attribute.
4 With the cursor in the qualification text box, choose Edit>Insert
Subquery.
5 In the Insert Subquery dialog box, select the subquery, then click
OK.

Building Advanced Queries 123


6 In the qualification text box, select an operator from the operator
list. (If the subquery is returning a single value, select =. If it’s
returning a list of values, select IN or NOT IN. The Begins with,
Contains, Ends with, Does not begin with, Does not contain, and Does
not end with operators are invalid for subqueries.)

7 If your query is complete, choose Query>Submit or save it for later


submission (see “Saving Queries” on page 64).

124 Building Advanced Queries


Modifying the SQL
If you understand SQL and your database, you can modify the SQL If you click Show
string generated by BI/Query when you formulate a query. However, Prompt Values in
the Query win-
you can’t directly modify the SQL for queries in which the results have dow, the SQL dis-
been modified (see “Ordering Columns” on page 58 and “Sorting plays the values you insert
Rows” on page 60) or combined with other results (see “Combining into prompts. If you don’t
insert values into prompts, the
Queries” on page 129).
Show Prompt Values option
displays the SQL without the
You must have the Edit Queries permission to modify the SQL.You
qualification or operator.
also need the Show SQL String preference to display the SQL in the
Query window. You can then modify anything after the SELECT
statement (subject to any restrictions placed on you by the DBMS).

BI/Query must recognize the format of data sent to the DBMS. If it


doesn’t, the results may have missing, misaligned, or otherwise
incorrect columns. This restricts the changes that you can make to the
SQL string. A good general rule is to not change anything before the
WHERE clause. That is, don’t change the attributes you’ve selected,
and don’t delete, add, or change the function you’ve applied to them.
Changes you make to the SQL string should be the last changes you
make to a query. If you modify the SQL string incorrectly, the DBMS
may return an error message.

To modify the SQL string


1 Make sure that you have the Edit Queries permission and the Show
SQL String preference. (Choose Tools>Permissions or
Tools>Preferences.)
2 Choose Query>Show.

Building Advanced Queries 125


While the length
of the SQL state-
ment depends
only on available
memory, when you edit it in
the Query window, it accepts
up to 65,535 bytes. This
allows you to create queries
with thousands of values and
large numbers of calculated
attributes.

3 Make the change(s) you want. (When you specify attributes in the
SQL string, use their database names, not the names in the attribute
window.)
4 If BI/Query displays a warning, click OK to overwrite the SQL
string.
OR
Click Cancel to undo your changes.

Modifying a Query for Selected Results


If you want to retrieve more detailed data about specific results you’ve
retrieved, you can do so in ad hoc drill-down mode. In this mode, you
select one or more results cells, then submit a query that returns results
only for those values.

When you select a single cell, {drilldown} appears in the qualification


tree instead of the contents of the cell. When you select more than one
cell, the list icon appears; you can use it to view and modify the list of
cells you selected. (For information on using the list icon, see “List
Icon” on page 33.)

126 Building Advanced Queries


To modify a query for selected results
1 In the results window, choose Results>Ad Hoc Drill Down. To cancel ad hoc
drill-down mode,
2 Select the cell(s) on which to base your query.
choose Results>
Ad Hoc Drill
Down or simply display
another window.

The original query returns a list of retailer names, locations, and sales amounts.
Cells you select using Ad Hoc Drill Down are light grey.

3 To retrieve results that match these items, resubmit the current query.
OR
To retrieve different results for these items, modify the current
query, then submit it.

Provides a list of cells selected


in the results window

4 To work with the same subset of results later, save the new query.

Building Advanced Queries 127


The query retrieves only the records for retailers with the six largest sales amounts
and includes the dates on which the sales were placed.

Narrowing the Range of Results


You can narrow To help you analyze your data, you can focus on a particular range of
the results before results. Specifying a range for results includes only the rows within that
you submit a
range. For example, you can specify retailer credit limits between
query by qualify-
ing an attribute with the $200,000 and $600,000, sales received between June 30 and December
BETWEEN function (see 31, and salespeople’s names between the letters A and S. You can also
“Finding a Range of Values” focus on results outside a range.
on page 45).

These results have no range applied. These results are for retailers with credit
limits between $200,000 and $600,000.

To narrow the range of results


1 Create or load a query.
2 Choose Query>Super Queries>Show Super Query.

128 Building Advanced Queries


3 In the Super Query window, select a component query or
operation, then choose Query>Add Operation>Range.
4 In the Range Filter dialog box, click a column, then type a range
into the Minimum and/or Maximum text boxes. (For character
data, type the values using the correct case.)

5 To obtain results outside a range, click Not in Range.


6 Click OK.

Combining Queries
To focus on specific information and create more complex queries, you
can create a query that combines results. This super query gives you the
flexibility to perform join operations not specified in a design window
or supported by your DBMS. You can also combine results from
different databases and design windows, and place two or more related
results sets (for example, retailer sales for Europe and retailer sales for
North America) in one report. However, you can’t save a super query
as a data values query file (see “Creating Data Values Query Files” on
page 90) and you can’t save the SQL for the super query as a text file
(see “Saving Results to a File” on page 157.)

You combine queries by appending the rows of one results set to


another or by joining columns of results sets.

Building Advanced Queries 129


Once you’ve combined queries, you can submit the resulting query to
retrieve the combined results. You can also link the combined query to a
button to perform these operations automatically. (For more information
on buttons, see the BI/Query Data Models Guide.)

This query appends the rows of one results set to another.

Appending One Results Set to Another


You can append the rows of one query’s results to another — even if
the data is derived from two different tables. For example, if one set of
results is for retailer sales during the first quarter and another is for
retailer sales during the second quarter, you can append one set to the
other to include sales for both quarters in the same report.

The data types of the columns in the first results set must match the
corresponding columns in the second results set. For example, if the
first results set contains two columns, and their data types are character
and numeric, respectively, the first two columns of the second results set
must also be character and numeric.

The two results sets can have a different number of columns as long as
the extra columns appear at the end of one set. Or you can exclude the
extra columns by hiding them. If the two results sets contain columns
with the same data type but in a different order, you can reorder them.
(For more information, see “Ordering Columns” on page 58.)

130 Building Advanced Queries


Query Results 1

Name aSales

Abicon Inc. $12,000

Textal Ltd. $113,000

Unisystems $10,145

Ziptech $6,430

Query Results 2

Name aSales State

Bainstream Inc. $10,000 New York

Campus Corp. $2,000 California

MonoLitho $2,100 Ohio

Textronics $60,000 Illinois

Appended Results

Name aSales State

Abicon Inc. $12,000

Textal Ltd. $113,000

Unisystems $10,145

Ziptech $6,430

Bainstream Inc. $10,000 New York

Campus Corp. $2,000 California

MonoLitho $2,100 Ohio

Textronics $60,000 Illinois

Building Advanced Queries 131


To append rows
1 Create or load a query.
2 Choose Query>Super Queries>Show Super Query.
3 In the data model, create or load a query you want to append. (If
necessary, reorder the columns in the query to match the order of
the first query.)
4 In the Super Query window, choose Query>Add Operation>
Append.
5 In the Append Rows dialog box, specify the results sets you want.

Appending rows from the second results set to the first. If the results sets have
different column names (for example, Retailer Name and Ret.Name), BI/Query uses
the name of the first set.

6 Click OK.

Joining One Column to Another


BI/Query supports join operations that allow you to retrieve and
manipulate data from more than one table. Typically, these join
operations are specified when the data model is created. However, you
can also join columns of results by using a join operation to combine
queries. You may want to join columns of results when:

• the design window doesn’t provide joins for the attributes you need
to join
• the data model doesn’t include permission to create relationships
between tables
• the database doesn’t support outer joins
• you want to combine results from more than one database

132 Building Advanced Queries


• after looking at the data you’ve retrieved, you see that you want to
join certain columns, but you don’t want to resubmit the
component queries (particularly if they took a long time to process
and you want to save time)
An equijoin includes only rows
If the design window provides the joins you need and you want to reuse that have an exact match in the
a set of joined results, consider creating and saving a standard query that columns that are joined.
retrieves the results rather than creating a query that combines the
results sets. Because the DBMS handles only one query, it may be able
to optimize the join operation more efficiently than BI/Query.

When you join results, you need to specify which columns should be A left outer join includes all
joined and how. That’s because you’re creating a relationship between rows from the left results set
the two tables. With the exception of columns containing float and and those that match from
the right.
money data types, connecting columns must have the same data type.

By default, BI/Query joins the columns you specify and includes only
the rows that have an exact match. In SQL terminology, this is an
equijoin. (BI/Query actually performs a type of equijoin called a natural
join, displaying the columns on which you join only once in the A right outer join includes all
rows from the right results
combined results set instead of twice.) In the example below, data set and those that match
about sales and payments have been retrieved from different tables. An from the left.
equijoin allows you to display only those sales for which payment has
been received.

You can also join results and have BI/Query include all rows from a
results set even if they don’t match. In SQL terminology, this is an outer
An outer join may even include
join. The example below shows that applying an outer join allows you all rows from both results sets,
to display all sales, regardless of whether payment has been received. even if they don’t match.
You can also apply a left or right outer join, as illustrated in the
diagrams on page 133.
BI/Query sup-
Query Results 1 ports ANSI
SQL/92 syntax
Sales # Sales Amount for left and right
outer joins for certain data-
101 $15,000 bases and connectivities. (For
more information, see the
102 $52,303 online Help.)

Building Advanced Queries 133


Query Results 1

213 $995

331 $2,561

511 $8,000

514 $2,303

818 $612

Query Results 2

Sales # Amount Received

101 $15,000

102 $52,303

331 $2,561

818 $612

Equijoin on Sales #

Sales # Sales Amount Amount Received

101 $15,000 $15,000

102 $52,303 $52,303

331 $2,561 $2,561

818 $612 $612

Outer Join on Sales #

Sales # Sales Amount Amount Received

101 $15,000 $15,000

102 $52,303 $52,303

134 Building Advanced Queries


Outer Join on Sales #

213 $995

331 $2,561 $2,561

511 $8,000

514 $2,303

818 $612 $612

To join columns
1 Create one of the queries you want to join.
2 Choose Query>Super Queries>Show Super Query.
3 In the data model, create or load another query.
4 In the Super Query window, choose Query>Add Operation>Join.
5 In the Join Columns dialog box, make sure the current query is
selected in the Choose a Query for the Bottom Branch text box.

The columns you join must have


the same data type

Building Advanced Queries 135


6 Choose the columns you want to join from the lists of columns.
7 To include all rows from one or both results sets, click Include All
Left Rows, Include All Right Rows, or both. (For more information,
see “Understanding Which Columns to Join” on page 136.)
8 Click OK.

Understanding Which Columns to Join

You can join on up to four columns. This is especially useful when the
primary key consists of two or more fields. By default, BI/Query applies
an equijoin, including only the rows in both results sets that have an
exact match in the joined columns. The columns you join appear once
in the combined results set. You can specify a different join using the
Include All Left Rows and Include All Right Rows check boxes.

To Include This Do This

Only rows that have an exact Leave Include All Left Rows and
match (equijoin). Include All Right Rows unchecked.

All rows from the left results set Click Include All Left Rows.
and those that match from the
right (left outer join).

All rows from the right results Click Include All Right Rows.
set and those that match from
the left (right outer join).

All rows from both results sets, Click Include All Left Rows and
even if they don’t match. Include All Right Rows.

Editing Combined Queries


You can submit
and save queries In a combined query, you can change each component query (each
by right-clicking query that makes up the larger query) and each operation performed on
the top pane of
the Super Query window, the results. For example, you can add an attribute to a component
then choosing the appropri- query, then change the sort order to include the new attribute. Editing
ate option. combined queries starts in the Super Query window.

136 Building Advanced Queries


Using the Super Query window
The Super Query window is divided into two panes separated by a
splitter bar, which you can use to resize the panes.

Toolbar
Operation
Component queries
Splitter bar

Message pane

The top pane displays the structure of the query using a tree list. Each
Icons
component query and each operation is included in the tree and is Query
represented by an icon. The operations performed on a component
Append
query’s results appear above the component query in the tree. For
example, if the results of a component query are reordered, then sorted, Join
the tree list shows three branches — first the component query, then Range
the reorder operation and the sort operation above it.
Reorder
If a join or append operation is performed on two of the component Sort
queries, it’s shown in the window above the queries and their
associated operations. Any operation that appears above a join or
append operation is applied to the results of the join or append.

Building Advanced Queries 137


When you’re
working with
complex queries, 8
you can see where 7
3
a join or append occurs by 2
collapsing the tree structure, 1
6
then expanding the branches 5
one by one. 4

How the Retailer Accounts query works


1 Retrieves the results of the Invoice Amounts query. 2 Applies a range to the results.
3 Sorts by Retailer #. 4 Retrieves the results of the Retailer Receivables query.
5 Reorders the columns. 6 Sorts by Retailer #. 7 Joins the results from step 3 with the
results from step 6. 8 Reorders the columns to produce the final query.

The bottom pane of the Super Query window (called the message pane)
displays information about an item in the query. When you select a
component query, the message pane displays the query’s SQL string.
When you select an operation, the message pane shows information
about what the operation does to the query results. And if there’s an
error in the query, the message pane displays information about why
the error occurred and how to correct it.

Editing a Component Query


You edit a component query by copying it from the Super Query
window into the data model. The component query then becomes the
current query, allowing you to open the appropriate attribute windows
and make your changes. When you’ve finished editing the query, you
paste it back into the Super Query window. (It’s not necessary to
submit the component query before you paste it.)

For example, suppose that a component query contains a date attribute


in a Sales data object and you want to add a qualification to the date
attribute. You copy the component query into the data model, then
open the Sales data object and apply the qualification. When you paste

138 Building Advanced Queries


the component query back into the Super Query window, BI/Query
Editing Guidelines
replaces the old component query with the new one.
When you edit queries in
the Super Query window,
If any errors occur as a result of making changes, you need to correct
follow these guidelines:
them before you can save and submit the final query. (See “Correcting
Errors” on page 140.) • Start with the innermost
query and work up
through the tree. This
To edit a component query makes it easier to
1 If the super query isn’t loaded, choose Query>Load. In the Load correct any errors.
Query dialog box, select it, then click Load. • Save your work
regularly.
OR
• Don’t modify the SQL
Choose Query>Super Queries>Show Super Query.
string — your changes
2 In the Super Query window, click a component query, then to the SQL won’t be
choose Query>Super Queries>Copy Query to Model. checked for errors.
3 Minimize the query window for the component query.
4 In the design window(s), make your changes to the component
query.
5 Display the Super Query window. If you can’t find
the Super Query
6 Click the component query you’ve edited, then choose
window, choose
Query>Super Queries>Paste Query from Model.
Window>More
7 Correct any errors. (See “Correcting Errors” on page 140.) Windows, then use the Select
Window dialog box to open
8 To save the query, choose Query>Save, specify a name for the
the window.
query, then click Save.
9 To submit the query, choose Query>Submit Query.

Editing an Operation
You can change how an operation manipulates query results by editing
the operation. You begin in the Super Query window. When you
double-click the operation you want to edit, BI/Query opens the
appropriate dialog box, where you can make your changes. When you
click OK, BI/Query replaces the old operation with the new one.

For example, if a range operation limits the results of a component


query to sales between $25,000 and $50,000, you can change the range
and the attribute the range is applied to. When you select the range

Building Advanced Queries 139


operation in the Super Query window, BI/Query opens the Range
Filter dialog box, where you can make your changes. When you click
OK, BI/Query replaces the old range operation with the new one.

You can’t edit an If any errors occur as a result of your changes, you need to correct them
append opera- before you can save or submit the query. (See “Correcting Errors” on
tion, but you can
page 140.)
delete it. Click the
append operation and choose
Query>Super Queries> To edit an operation
Delete Operation. 1 To load a query, choose Query>Load. In the Load Query dialog
box, select a query, then click Load.
OR
Choose Query>Super Queries>Show Super Query.
2 In the Super Query window, click an operation, then choose
Query>Super Queries>Edit Operation.
3 In the dialog box that appears, edit the operation.
4 Click OK.

Correcting Errors
Each time you edit a query in the Super Query window, BI/Query
checks for errors. You can’t save or submit a query that contains errors
— you need to correct the errors first. When you edit a query, you
may introduce an error because the parts of the query are
interdependent. For example, removing an attribute from a component
query when that attribute is used in a sort operation results in an error
in the sort.

Errors occur on operations, but you can correct them by editing either
the operation or its associated component query. For example, you can
correct the error described above by editing the component query to
include the missing attribute or editing the sort operation to sort on a
different attribute.

Most errors occur because an attribute used in an operation is missing


from the component query on which the operation is performed.

140 Building Advanced Queries


When an error occurs, BI/Query displays an error icon beside the
corresponding operation. When you click the operation, the message
pane in the Super Query window provides information about why the
error occurred and how to correct it. After you’ve corrected the error,
test the query by submitting it.

To correct an error
1 In the Super Query window, click the operation causing the error. Error icon

2 Read the information in the message pane.


3 Edit the component query or operation. (If you’re editing more
than one operation, start with the operation immediately above its
corresponding query and work up through the tree.)
4 To save the query, choose Query>Save, specify a name for the
query, then click Save.
5 To test the query, choose Query>Submit Query.

Common Errors and Their Solutions

The table below lists some common errors and their solutions.

Building Advanced Queries 141


Type of Error Reason and Solution

Append: Column n doesn’t match The attributes in the results you’re


appending don’t match for one of
the following reasons:
• you selected the attributes in the
first query in a different order
than the attributes in the second
• an attribute used in one query is
missing from another query
Edit the queries to reselect the
attributes in a consistent order.

Reorder Error: Missing Column An attribute in the operation is


Range Error: Missing Column missing for one of the following
Sort Error: Missing Column reasons:
• the attribute is missing from the
component query
• you hid the column with a
reorder operation
Do one of the following:
• edit the query to add the missing
attribute
• edit the reorder operation to
restore the hidden attribute
• edit the operation to use a
different attribute

Creating Dynamic Relationships


The relationships between data objects in a data model allow you to
formulate queries using more than one object. Rather than using all
possible relationships between data objects, the data model typically
provides only the most important ones. When data objects don’t have a
relationship, or when existing relationships don’t relate the attributes
the way you need them to be related, you can create dynamic
relationships. Dynamic relationships are typically created “on the fly” for

142 Building Advanced Queries


temporary use. To make use of dynamic relationships, you need to
understand the database and know how to draw related information
from more than one table.

Creating dynamic relationships requires the Dynamic Relationships


permission and the Allow Dynamic Relationships preference. Saving
the relationships requires the Save Data Model permission.

In order to create a dynamic relationship between two tables, you need


to decide the condition under which the data in one table is related, or
“joined,” to data in the second. That is, you need to specify a join
condition. For example, you can create a relationship between the
Retailer and Sales tables, where the Retailer Number attribute in one
table is made equal to the Retailer Number attribute in the other table.
A query that includes both data objects will then return data only for
retailer numbers that appear in both tables. (For more information on
join conditions, see “Creating Join Conditions” in the BI/Query Data
Models Guide.)

When you create a new relationship, it’s represented by a line joining


the two data objects in the data model. If you want, you can display a
relationship icon as well.

To create a dynamic relationship


1 Make sure that you have the Dynamic Relationships permission
and the Allow Dynamic Relationships preference and, if you’re
going to save the relationship, the Save Data Model permission.
2 Select the two data objects you want to join, then choose Query>
Relationship.
3 In the Choose Relationship dialog box, select <dynamic> from the
relationship list.

Building Advanced Queries 143


Relationship list Operator list
Choosing an Operator
The default = operator is
the most common type of
relationship; it specifies
that the value of an
attribute from one table
equals the value of an
attribute from another.
You may need to consult
your administrator to
ensure that the relation-
ships you create use the
appropriate join conditions
and produce the results
you want.

Data object lists

4 Select an operator from the operator list. (The default operator is


“=”.)
5 Click an attribute in the left-hand list.
6 Click an attribute in the right-hand list, then click Add.
7 Click OK.
8 To save a relationship and name it, choose Query>New.
9 In the Save Query dialog box, click Save.
10 In the Save Dynamic Relationship dialog box, specify a relationship
name. (For information on naming relationships, see the BI/Query
Data Models Guide.)

Building Queries with a Circular Path


When the data model you’re using contains two or more data objects
whose relationships form a circular path, you can build queries that use
all the data objects and all the relationships in that path. For example, if
the data model contains the Employees and Departments data objects,
and they’re connected by the Work In and Managed By relationships,
you can build queries that use both data objects and both relationships.

144 Building Advanced Queries


Because each data object in a circular path has two relationships,
BI/Query prompts you to specify whether you want to create a
correlation (also called an alias). The choice you make determines how
join conditions are applied in your query and the extent to which your
results are restricted. A query that uses a correlation allows you to ask
two questions of the same data object and is usually less restrictive than
a query that doesn’t use a correlation.

Queries with a circular path are typically built by advanced users who
understand how to use join conditions in order to retrieve the
information they need.

With a Correlation
When you build a query with a correlation, BI/Query creates a When administra-
temporary copy of the data object. This allows you to ask two different tors design a data
model, they can
questions of the same object.
create permanent
copies of a data object using
You begin by selecting the relationships joining the data objects you
correlation names. In some
want to include in your query. The last relationship you select cases, this allows users to
determines how the circular query is formed. The data objects avoid building circular que-
connected to that relationship are the ones you’re presented with when ries. (See the BI/Query Data
Models Guide.)
you’re prompted to create a correlation. And that relationship is applied
to the data object you create a correlation for.

For example, if you select the Managed By relationship last and create a
correlation for Employees, BI/Query creates a second, temporary copy
of Employees called Empo__Manag. (To name the correlation,
BI/Query uses the first five characters of the data object’s name, two
underscores, then the first five letters of the relationship you selected
last.) The result is two copies of Employees: one connected to
Departments through the Work In relationship, the other, temporary
copy connected to Departments through Managed By.

Building Advanced Queries 145


This is what you see in the Behind the scenes, BI/Query creates
design window. temporary copy of Employees and connects it to
Departments using the Managed By relationship.

When you double-click the original data object in the design window,
you’re prompted to specify which attribute window you want to use
— the one for the original data object or the one for its correlation.
You can use one attribute window to ask one question, then the other
attribute window to ask the second question.

For example, suppose you want to use the data objects illustrated above
to find out which employees work for managers who make over
$60,000. You need a correlation because you’re asking for two kinds of
information from the Employees data object — the names of the
employees and who is a manager making over $60,000. You’d use the
Employees data object to find out the names of the employees, and
you’d use its correlation to find out who is a manager making over
$60,000. (You use the correlation for the second question because it’s
the one that uses the join condition in the Managed By relationship.)

When you submit the query, the DBMS processes it in two stages.
Behind the scenes, the DBMS first obtains a preliminary results set
(names of all employees and the departments they work in) by joining
each row in Employees with each row in Departments, then applying
the join conditions for Work In.

Departments X Employees- = Results


--------------------------------------------------------------- 1
Work In

146 Building Advanced Queries


The DBMS then applies the join condition for Managed By to the
preliminary results set and Emplo__Manag (the copy of Employees) to
retrieve the final results (employees who work for managers making
over $60,000).

Results 1 X Emplo__Manag
----------------------------------------------------------------- = Results Final
Managed By

This is the SQL that this query generates.

select
Employees.LastName,
from
Departments,
Employees,
Employees Emplo__Manag
where
(
(
Emplo__Manag.Salary > 60000.0000
)
)
and
Departments.DepartmentID = Employees.DepartmentID
and
Departments.Manager = Emplo__Manag.EmployeeID ;

To build a query with a circular path that uses a correlation


1 Decide which data object you want to create a correlation for and Because circular
which relationship to use for that correlation. queries are com-
plex, it’s good
2 Click the relationships joining the data objects you want to include.
practice to start by
(Make sure that the last relationship you click is the one you want building one that returns a
to use for the correlation.) small subset of data. This
3 In the Circular Query Option dialog box, click the data object you allows you to test the design
want to create a correlation for. of the query before you sub-
mit it (and possibly retrieve a
large number of rows).

Building Advanced Queries 147


4 Click OK.
5 In the design window, double-click the data object you created the
correlation for.

Double-click Employees to open the attribute windows for Employees and for its
correlation.

6 In the Open Attribute Windows dialog box, select the attribute


window(s) you want to open.

Choosing Employees opens the attribute window for the original Employees data
object. Choosing Emplo__Manag opens the attribute window for its correlation.

148 Building Advanced Queries


7 Click OK.
8 In the attribute window(s), click the attributes you want to include
in the query, then close the window(s).
9 Click any other attributes you want to use from the other data
objects in the circular path.
10 To maintain all the join conditions in the query, choose Query>
Modifiers>Trim Relationships to deselect it.
11 Choose Query>Submit Query.

Without a Correlation
When you build a query without a correlation, BI/Query doesn’t
create a temporary copy of a data object in the circular path. This
allows you to ask one question using all the data objects and all the join
conditions in the circular path. The results are usually more restricted
because the rows returned from the database must meet all the join
conditions in the circular path.

In a circular query without a correlation, the DBMS returns only the rows that meet the
join conditions in both the Work In and Managed By relationships.

Building a query without a correlation is similar to building a query


with a correlation except that the order in which you select the
relationships isn’t important. When BI/Query prompts you to specify
whether or not to create a correlation, you choose not to create one.

For example, suppose you want to use the data objects illustrated above
to find out which employees make over $60,000 and manage the

Building Advanced Queries 149


department they work in. You need a circular query, but you don’t
need a correlation because you’re using each data object only once.

When you submit the query, the DBMS processes it in two stages.
Behind the scenes, the DBMS first obtains a preliminary results set
(names of all employees who make over $60,000 and the departments
they work in) by applying the join condition for Work In to
Departments and Employees.

Departments X Employees
---------------------------------------------------------------- = Results 1
Work In

The DBMS then applies the join condition for Managed By to the
preliminary results set to obtain the final results (employees who make
over $60,000 and manage the department they work in).

Results 1
-------------------------------
- = Results Final
Managed By

This is the SQL that this query generates.

select
Employees.LastName,
from
Departments,
Employees
where
(
(
Employees.Salary > 60000.0000
)
)
and
Departments.DepartmentID = Employees.DepartmentID
and
Departments.Manager = Employees.EmployeeID ;

To build a query with a circular path that doesn’t use a correlation


1 Click the data objects and relationships you want to include in the
query.
2 In the Circular Query Option dialog box, click No Correlation.

150 Building Advanced Queries


3 Click OK.
4 In the design window, double-click the data objects in the circular
path.
5 In the attribute window(s), click the attributes you want to include
in the query, then close the attribute windows.
6 Choose Query>Submit Query.

Building Advanced Queries 151


Exporting Information

Exporting Queries 155


Exporting Results 156
Copying and Pasting Results 157
Saving Results to a File 157
Exporting Results to an Application 158
Preparing Results for Export 159
Specifying Results Options 159
Setting Export Options 161
Exporting to Excel Using DDE 163
Common DDE Commands 163
Setting Export Options for Excel 164
Using Two Commands 164
Using the First Command only on Startup 165
Issuing Two Commands to Obtain the Effect
of Three 165
Combining Three Results Sets 166
Sending Current Results to Excel 167
Running a Macro That Calculates a 12-month
Moving Total 168
Export Results Using Mail 169
Exporting Information
You can extend the usefulness of your BI/Query queries and results
sets by exporting them to other applications to produce powerful
worksheets and other documents. You can export the underlying SQL
for queries that have not been filtered or combined, and you can export
query results. You can save query SQL and results files for use in other
applications, and you can create buttons to export results automatically
using DDE or menu commands. You can also distribute by electronic
mail the query SQL files and results files that you’ve created.

Exporting Queries
If you have the Save Queries permission, you can export the SQL for a
query to a text file, provided that the query does not manipulate the
results. (See “Ordering Query Results” on page 58, “Narrowing the
Range of Results” on page 128, and “Combining Queries” on
page 129.) The SQL can then be used in other applications. For
instance, you can use saved SQL in stored procedures in the database.

When you export a query from a results window, BI/Query saves the
query that generated that results set. When you export from any other
window, BI/Query saves the current query.

To export the SQL for a query


1 Make sure you have the Save Queries permission.
2 Load, build, or run the query you want to export.
3 Choose Query>Save.
4 In the Save Query dialog box, click Export SQL Only, then click
Export.

Exporting Information 155


5 In the Save Query SQL dialog box, specify the name and location
for the file if you want these to differ from what is displayed, then
click Save.

Exporting Results
Query results are useful in BI/Query — and they’re also valuable when
they’re exported to other applications. BI/Query exports results as text
files that can be used by any application. For example, you can augment
a report prepared in Microsoft Word by including actual data that
you’ve retrieved from a query or you can transfer results to a worksheet
in Microsoft Excel to perform advanced statistical analyses.

156 Exporting Information


You can export results using the following mechanisms:

• Copy results and paste them into another application. (See


“Copying and Pasting Results” on page 157.)
• Save results to a file and open the file in another application. (See
“Saving Results to a File” on page 157.)
• Create a button that exports results to another application using
Microsoft’s Dynamic Data Exchange (DDE) facility or using menu
commands in that application. (See the table on page 158.)

Copying and Pasting Results


An easy way to export results is by copying them in BI/Query and
pasting them into the other application.

To copy and paste results


1 In a results window, select the results you want.
2 Choose Edit>Copy.
3 In the target application, paste the results you copied (in many
applications, Ctrl+V will paste copied material).

Saving Results to a File


You can make results available to other applications by exporting the
results to a text file. Before exporting results, be sure that they’re
properly set up. (See “Preparing Results for Export” on page 159.)
You can also create a button that automatically saves the results of a
query to a file. (See the BI/Query Data Models Guide.)

To save results to a file


1 Submit a query so that the results are saved directly to a file by
choosing Query>Submit Query>To File.
OR
In a results window, choose Results>Save As>Results.
2 In the Save Query Result to File dialog box, specify the name and
location of the file, then click OK.

Exporting Information 157


3 Open the results file in the target application.

Exporting Results to an Application


A data model can include a button that exports results directly to
another application using one of two mechanisms — menu commands
or Microsoft’s Dynamic Data Exchange (DDE). If you have the Edit
Data Model and Save Data Model permissions, you can create such a
button. (See the BI/Query Data Models Guide.)

When you export results to another application, BI/Query copies the


results, then checks whether the receiving application is already
running and, if not, starts it up. Depending on the export mechanism,
BI/Query then calls the appropriate menu commands in the receiving
application or sends the DDE commands to the receiving application.

To Do This Use This

Export results by specifying the menu Menu Commands


commands to be executed in the receiving
application — for example, to instruct
Microsoft Excel to execute Edit>Paste to paste
the contents of the Clipboard into a document.

Include arguments in your commands that DDE


instruct the receiving application to carry out
more specific tasks than simply using menu
commands — for example, to open a particular
worksheet and run a macro. (See also
“Exporting to Excel Using DDE” on
page 163.)

Results must be set up properly in order to be exported directly to an


application. (See “Preparing Results for Export” on page 159.)

To use a button to export results to an application


1 Create a button. (See the BI/Query Data Models Guide.)

158 Exporting Information


2 In the Output section of the Create Button dialog box, click
Application, then click Export Options.
3 Specify export options, including an export mechanism (DDE or
Menu Item). See “Setting Export Options” on page 161.
4 In the text box, type the commands to be executed in the receiving
application.

Preparing Results for Export


Before you export results, you need to ensure that they’re properly set
up. There are three things to consider:

• display format — how numbers, characters, and dates are


represented (for example, Microsoft Excel doesn’t accept some date
formats allowed in BI/Query, like YY/MM/DD; see “Formatting
Data” on page 71)
• results options — settings required by the receiving application
• export options — the receiving application, the export mechanism,
and the commands to be executed

Specifying Results Options


When you save results to files and export them to other applications, be
sure to specify the results options required by the receiving application.
For example, a worksheet application may require double quotation
marks around textual data. (If you’re not sure what the receiving
application requires, check its documentation.)

You can specify results options in the following ways:

• As data model preferences — Specified in the Preferences dialog


box and applied thereafter to all new results sets and new buttons.
• For a particular results set — Specified after retrieving results, with
the results window active; for this results set, overrides the options
specified as preferences.
• When you create a button — Specified in the Create Button dialog
box; for this button, overrides the options specified as preferences.

Exporting Information 159


To specify results options
1 To specify default results options, choose Tools>Preferences. In the
Preferences dialog box, click Results Options.
OR
To specify results options for a particular results set, choose
Results>Options.
OR
To specify results options when you’re creating a button to
automate exporting or saving theme, in the Create Button dialog
box, click Results Options.
2 In the Results Options dialog box, specify the option(s) you want.
(These options are described in the table below.)

3 Under Separators, specify the separator(s) you want in the Field,


Record, and End of File text boxes. (Select them from the lists or
type any valid ASCII characters, such as ^D for Control-D (ASCII
004), <LF> for a line feed, <CR> for a carriage return, and
<TAB> for a tab character. For more details, see the table below.)
4 Click OK.

160 Exporting Information


This Option Does This

Save Query Includes the name of the query that generated the
Name results. This is useful when you’re exporting to
applications that use worksheet macros to perform
certain operations depending on which query
generated the data.

Save Column Includes results column headings in a block of


Headings results that’s saved or copied.

Save Prompts Includes information about the prompts used in the


query — for each, the number of prompts followed
by a record separator, the prompt ID followed by a
field separator, the number of values used in the
prompt followed by a field separator, and the actual
prompt values separated by field separators.

Text in Quotes Inserts double quotation marks around textual data.

Transpose For results saved to a file, transposes rows and


A D
columns so that the data is stored by columns rather
than rows (for example, the first row of results A B C B E
becomes the first column of data); not available D E F C F
when you create buttons.
Original Transposed
Field A character or sequence of characters that separates
Record each value in a row (normally a tab character),
End of File separates each row of data (normally a carriage
return), and indicates the end of the file (normally
no character).

Setting Export Options


When you export results to other applications, you need to specify the
application to which the results will be exported, the export mechanism
you’re using, and the commands to be executed in the receiving
application. (To determine the requirements of the receiving application, see
its user documentation. You may also need the help of your administrator to
find out whether an application supports DDE and what service name to use.)
You can specify export options as a preference or when you create a

Exporting Information 161


button. Specifying export options in the Preferences dialog box applies
the options to buttons created thereafter. Export options specified from
the Create Button dialog box override the options specified as
preferences.

To set export options


When you create 1 To specify default export options, choose Tools>Preferences. In the
a button to export Preferences dialog box, click Export Options.
results using
DDE, the button’s
OR
DDE command may contain To specify export options when you’re creating a button, in the
a macro that’s stored in a Create Button dialog box, click Export Options.
shared network folder or in
different locations on users’
2 In the Export Options dialog box, select the application to which
computers. If when you click you’re exporting from the Application list. (If it isn’t in the list,
the button, BI/Query can’t select User Defined, then specify the file. The application name must
find the file, it captures the be the same as the name that appears in the title bar of the
path to Excel’s Macro Library application. It can be up to 256 characters.)
and inserts it into the button’s
DDE command.

3 If the executable for the application isn’t in your path, click the
button to the right of the Execute Command Line text box. In the
Select Application dialog, find and select the application, then click
Open.
4 If you’re exporting using DDE, and it isn’t supplied automatically,
supply the name that the application registers with the DDE server
into the Service Name text box.
5 Under Commands, click DDE or Menu Item.

162 Exporting Information


6 Type the commands to be executed in the receiving application.
(The menu command mechanism requires the format “menu
command|command”.)
7 Click OK.

Exporting to Excel Using DDE


This section provides more information about exporting to Excel using
DDE as well as a number of examples. DDE (Dynamic Data Exchange) is
a form of inter-application communication in Windows and OS/2 that
allows applications to exchange information and commands.

Common DDE Commands


Here are some common command sequences used to send results to
Microsoft Excel using DDE. Some of them are used in the examples
that follow. For other commands, see your Excel user documentation.

To Do This Use This Command

Paste the results to a work- [paste()]


sheet already open in Excel.
Or, if Excel is not already
running, run Excel, open a
new worksheet, and paste the
Clipboard contents to it

Paste the results to a new [new()]|[paste()]


worksheet in Excel

Open the test.xls worksheet [open(“c:\msoffice\excel\test.xls”)]


(if Excel isn’t already [paste()]
running) and paste the results
to it

Open the test.xlm macro [open(“c:\msoffice\excel\test.xlm”)]


sheet, then run a macro on [run(“test.xlm!macro1”)]
that sheet

Exporting Information 163


To Do This Use This Command

Open the test.xls worksheet, [open(“c:\msoffice\excel\test.xls”)]


open the test.xlm!macro1 [run(“test.xlm!macro1”)]
macro sheet, and run a macro

Open the test.xlm! macro [run(“test.xlm!macro1”)]


sheet, then run the macro1
macro on that sheet (where
the macro sheet is in the
BI/Query data model folder
or the macro is on the global
macro sheet)

Setting Export Options for Excel


When you set export options for Excel, the default command —
[Paste()] — appears automatically in the Commands text box. When
you export your results, BI/Query starts up Excel if it isn’t already
running, then instructs it to paste the contents of the Clipboard (the
query results) into a worksheet.

Using Two Commands


Instead of using the default [Paste()] command in the Commands text
box, you can substitute up to two commands — for example, to open a
specific worksheet and paste results. If you’re content with a generic

164 Exporting Information


worksheet, you can open a macro sheet, run a macro on that sheet,
then save it using another name. Unless a macro is on the global macro
sheet, you must first open its macro sheet.

Using the First Command only on Startup


If the first of two commands is to be executed only once (such as
opening a specific worksheet on startup), use the | (pipe) symbol
between the two commands: [open(.........)]|[run(.............)]. Be sure
to also use the pipe symbol to prevent Excel from opening a worksheet
that is already open or pasting results into an open worksheet and
overwriting the contents. The first command is sent only if the
application isn’t already running and BI/Query must start it up; the
second command is always sent, even when the application is already
running. Specify all arguments for each command. The pipe symbol is
not necessary if it’s logical for both commands to run each time you
export results. (The pipe symbol has a different purpose here than when
you export results using menu commands.)

Issuing Two Commands to Obtain the Effect of Three


When you open a specific worksheet and run a macro, you’re doing
three things — opening a specific worksheet, opening a specific macro
sheet, and running a macro. You can carry out these three commands
using two in order to use the DDE export mechanism. The two
commands would look like this:

[open(“c:\msoffice\excel\test.xls”)]|[run
(“test.xlm!macro1”)]

To issue two commands to obtain the effect of three


1 Attach Excel’s auto_open function to your worksheet so that your
macro sheet opens whenever the worksheet opens. Do this by
opening the worksheet, then choosing Formula>Define Name.
Specify a name such as Auto_open, then use the following syntax in
the Refers To text box: =test.xlm!open_macro.

Exporting Information 165


2 Place the macro on the global macro sheet (global.xlm). This sheet
is opened automatically with Excel and doesn’t require a command.
Using it cancels opening a default worksheet, but that function can
be included in the macro if needed. The disadvantage to this
approach is potentially developing a global macro sheet containing a
lot of specific macros that aren’t useful in a global sense.
3 Place the macro sheet in your path or in the subdirectory of the data
model you’re using. This is somewhat unorthodox, but the effect is
the same as placing the macros on the global macro sheet, and it has
the advantage of grouping the macros in a separate sheet.

Combining Three Results Sets


You can easily combine the results of more than one query in an Excel
worksheet. This is useful when you’re using data from different tables
or when you’re using a combined query.

To combine three results sets


1 Create three buttons in BI/Query, then link each one to a query.
Link each button to a macro that positions the cursor in Excel, then
pastes the results to the appropriate spot on the default worksheet.
Click each button in turn. Don’t close Excel until all three buttons
have sent their results; otherwise, you’ll create three separate
worksheets. For example, set up the buttons with these macros:

This Button Executes This Macro

Button A [open(“c:\msoffice\excel\test.xlm”)]
[run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

If the macro sheet is in the BI/Query data model folder, or if the


macros are on the global macro sheet (see “Issuing Two Commands
to Obtain the Effect of Three” on page 165), you can accomplish
the same result using the following macros:

166 Exporting Information


This Button Executes This Macro

Button A [run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

2 Create a button that selects the current query, then exports the
results using the default paste to Excel. This method reduces the
number of buttons but requires you to load each query in
BI/Query before running it. You must also reposition the cursor in
Excel each time so that the next set of results does not overlap.
3 Paste to a specific worksheet. Open the macro sheet by following
one of the instructions in “Issuing Two Commands to Obtain the
Effect of Three” on page 165. Then use the following macros:

This Button Executes This Macro

Button A [open(“c:\msoffice\excel\test.xls”)]
[run(“test.xlm!macro1”)]

Button B [run(“test.xlm!macro2”)]

Button C [run(“test.xlm!macro3”)]

Sending Current Results to Excel


You can create a button that exports the results of the current query to
Microsoft Excel using DDE. Using a button saves time when you
export data regularly to Excel. Clicking the button in this example
selects the results displayed in the results window, copies them to the
Clipboard, runs Excel, opens a new worksheet, and pastes the results.

If your Excel worksheet always uses the same format, set up a template
worksheet. Specify an export command that opens the template and
pastes the results, such as [open(“c:\msoffice\excel\template.xls”)][paste()].
Once the results are copied, save the template with another name.

Exporting Information 167


To send current results to Excel
1 Create a button. (See the BI/Query Data Models Guide.)
2 Under Appearance, specify the name of the button, such as Send
Current Query to Excel.
3 Under Linkage, select Current Query.
4 Under Output, click Application.
5 Click Export Options and specify the application to which the
results should be exported (Microsoft Excel) using DDE.

Running a Macro That Calculates a 12-month Moving Total


You can create a button that exports the results of a query to Microsoft
Excel using DDE, opens a worksheet, and runs a macro that calculates a
12-month moving total.

To run a macro that calculates a 12-month moving total


1 In Excel, create the macro.
2 In BI/Query, in Design Mode, choose Layout>Create Button.

168 Exporting Information


3 Under Appearance, specify the name of the button, such as Send
Current Query to Excel or Create 12-month Moving Total.
4 Under Linkage, select Current Query.
5 Under Output, click Application.
6 Click the Export Options button and specify the application to
which the results should be exported (Microsoft Excel) using DDE.

Export Results Using Mail You can retrieve


BI/Query files
If you’re running an electronic-mail application on your computer, you using mail. Run
your mail client
can export BI/Query files as attachments with your mail messages. Mail
and retrieve the files into the
provides an easy way to distribute new and revised queries and results appropriate folders. (For
to others. If you use an electronic-mail application that supports query files, this is the Queries
Microsoft’s Messaging API (MAPI), such as Microsoft Mail, you can folder. For results, this is the
folder where BI/Query is
mail files directly from BI/Query.
stored; be sure to retrieve
both .qrd and .qrr files.) To use
When you send mail from BI/Query, the application starts up your
retrieved files, close the data
mail client. (For information on using your mail client, see the model if it’s open, reopen it,
corresponding documentation.) If you build a query before starting up then open the files.

Exporting Information 169


mail, BI/Query automatically encloses the corresponding .qry file in
your message — regardless of which window you’re working in. If you
retrieve a results set, then start up mail, the corresponding .qrd and .qry
files are enclosed only if the results window is the active window. To
automatically enclose a results set, display the results window before
running mail. If you don’t want to include the current query or results
set in a mail message, remove the file from the enclosure.

To send mail from BI/Query


1 Choose File>Send.
2 Specify a recipient and subject and enclose any additional files.
3 Send the message.

170 Exporting Information


Index 1
A creating, 51, 55–57
data formats, 71–75
actual relationships, qualifying, 96 data objects with, 15, 16
Ad Hoc Drill Down command, 127 data values, displaying, 34–37
ad hoc drill-down mode, 126–128 functions, applying, 47–57
ad hoc queries, 29 grouping, 47–49, 51–55
Add Operation command, 129 in variables, 108
adding ordering, 58
attributes, 51, 55–57 sorting, 60–63
colors, 78–79 AVERAGE DISTINCT function, 50
qualifications. See qualifying AVERAGE function, 50
rows of results, 130–132
See also creating
administrator layer
files, 23
B
finding, 24 BI/Analyze, 11
reestablishing path to, 24 BI/Broker, 10
aggregate functions, 47–54, 56, 57 BI/Broker Admin, 10
alarms, 78–79 BI/Broker Repository, 10, 21
aliasing data, 93–96 See also repository
Allow Dynamic Relationships preference, 143 BI/Query Admin, 11
appending rows of results, 130–132 BI/Query Reports, 11
applications BI/Query Update, 11
BI/Analyze, 11 BI/Query User, 11
BI/Broker Admin, 10 BI/Query, 10–11
BI/Broker, 10 overview, 3, 15–18
BI/Query Admin, 11 starting, 21–23
BI/Query Reports, 11 BI/Suite, 9–11
BI/Query Update, 11 BI/Web, 10
BI/Query User, 11 building queries. See queries
BI/Query, 10–11 buttons, 18, 160
BI/Suite, 9–11 creating. See BI/Query Data Models Guide
BI/Web, 10 split data models with, 24
Business Intelligence, 8–12
Genio Suite, 8–9
Hummingbird, 8–12
Scheduler, 10
C
User and Group Manager, 10 Cache Passwords permission, 26
attributes, 15, 16 calculated attributes, 51, 54, 55–57
adding, 51, 55–57 calculations
calculated, 51, 54, 55–57 in variables, 108
calculations on, 47–57 with attributes, 47–57

Index 171
calculations (continued) copying, using Clipboard, 157
with queries, 47–57 correlation names, 145
canceling ad hoc drill-down mode, 127 Count All command, 52
Case-sensitive Comparisons preference, 33 COUNT DISTINCT function, 51
characters, special, 77–78 COUNT function, 50, 54
circular queries, 144–151 creating
no correlations, 149–151 attributes, 51, 55–57
with correlations, 145–149 circular queries. See circular queries
Clipboard, exporting to, 157, 157 data models. See BI/Query Data Models Guide
colors, using, 78–79 data values
Column Order command, 59 query files, 90–93, 103
columns results files, 88–90
in results nested queries, 123–124
hiding, 130 prompts, 97, 99–100, 102
joining, 132–136 queries. See queries
ordering, 58, 130 relationships, 142–144
Combine command, 42 subqueries, 123–124
combining variables, 108–115
qualifications 35, 41–42 customer support, 5–6
queries, 129–136
comparison operators, 43–44
computed strings, 78–79 D
condition box, 39–40, 42
conditional prompts, 97, 101–106 data
conditions, applying. See qualifying aliasing, 93–96
Connect command, 25–26 entering, 71–73
connecting to DBMS, 26 formats, 71–75
default connection files, 25–26 colors, 78–79
supplying connection information, 26 dates, 71–72, 73, 77
connection files, 26 default, 71
omitting information, 26 numbers, 71–73, 76
Connections command, 25 strings, 77
contacting Hummingbird groups, 49–55
Professional Services, 7–8 substituting values, 78–79
Sales, 12 data models
Technical Support, 6 creating. See BI/Query Data Models Guide
Contents command, 5 data objects, 15
Control Panel settings, 71, 71–73 editing, 24
conventions in this guide, 3 files, 23
converting two-digit years, 73–75 opening, 23
Copy command, 157 split, 23
Copy Query to Model command, 139 data objects, 15

172 Index
attributes, 15 exporting to Excel, 163–169
connecting, 142–144 default
qualifying, 96 connections, 25–26
relationships between, 142–144 data format, 71, 75
data types, 55 text styles, 71
Data Values command, 36 deleting
Data Values folder, 85 calculated attributes, 55
Data Values Results command, 88, 90 characters in a string, 77
data values, 35–36, 83–96 qualifications on attributes, 33, 35
access, 84 displaying
aliasing data, 93–96 data values, 34–37
disabling, 84 data, 71, 75–79
displaying, 34–37 Distinct command, 88, 89, 92, 103
files, 83–96 documentation
icon, 34–37 conventions, 3
in variables, 108 electronic, 4
prompts, using with, 85–86, 103 related documents, 4–5
qualifying attributes with, 34, 35–36, 83 duplicate information, suppressing, 50
query files, 83–86, 90–93 Dynamic Relationships permission, 143
creating, 90–93, 103 dynamic relationships, 142–144
naming, 85–86
prompts with, 85–86, 103
results files, 83–90 E
creating, 86–90
naming, 85–86 edit mask, 78–79
prompts with, 85–86 Edit Operation command, 140
spreadsheet, using to create, 89–90 Edit Queries permission, 125
text editor, using to create, 89–90 editing
database, connecting to, 26 buttons, 24
Date Entry command, 74 calculated attributes, 55
dates data formats, 75–79
calculating in variables, 107, 109 ornaments, 24
entering, 33 qualifications. See qualifying
fixed, 73–75 queries, 125–126
formats, 71–72, 73, 77 SQL string, 125–126
sliding, 73–75 electronic documents, 4
DBMSs e-mail address, Hummingbird, 6, 8, 12
connecting, 26 enhancements, suggesting, 6
default connection files, 25–26 equal joins, 133–136
Teradata, 55 errors, editing, 140–142
DDE, 157, 158, 162–169 Excel, exporting to, 162, 163–169
commands, 163–164 exception reporting, 78–79

Index 173
exporting, 155–170 aggregate, 47–57
buttons, using, 157, 160 AVERAGE DISTINCT, 50
Clipboard, using, 157 AVERAGE, 50
DDE, using, 158, 162, 162–169 COUNT DISTINCT, 51
mailing files, 169–170 COUNT, 50, 54
queries, 155–156, 169–170 group order, 47–49, 51–52, 57
reports, 170 in variables, 108
results, 67–68, 156–163, 169–170 MAXIMUM, 50
format, 159–161 MINIMUM, 50
to Excel, 162, 163–169 none, 50
expressions. See variables qualifying attributes, 53–54
scalar, 57
SUM DISTINCT, 50
F SUM, 47, 48, 50, 52

fax, Hummingbird, 6, 8, 12
files G
data values
query, 83–86, 90–93, 103 Genio Suite, 8–9
results, 83–90 Group Qualification command, 53
exporting to, 157, 159–161 group qualification, 53–54
mailing, 169–170 grouping
names, 85–86 attributes, 47–49, 51–55, 57
Prompts, 106, 108 prompts, 97, 98–106
prompts, 97
queries, 68, 155–156
reports, 170 H
results, 67–68, 157
finding adminstrator layer, 24 HAVING clause, 53–54
fixed dates, 73–75 help
Format command, 75 obtaining technical support, 5–6
formats online, 5
data, 71–75 Help menu. See specific commands
colors, 78–79 hiding columns in results, 130
default, 71 hierarchical prompts, 97, 98–106
substituting values, 78–79 How to use Help command, 5
dates, 33, 71–72, 77 Hummingbird
numbers, 71–73, 76 BI/Analyze, 11
results, 159, 159–161 BI/Broker, 10
strings, 78–79 BI/Query Admin, 11
four-digit years, converting to, 73–75 BI/Query Reports, 11
functions, 47–55 BI/Query Update, 11

174 Index
BI/Query User, 11 list icon, qualification tree, 33
BI/Query, 10–11 Load Query command, 139, 140
BI/Suite, 9–11 lock icon, 24
BI/Web, 10 logging in to BI/Broker, 21–22
e-mail address, 6, 8, 12
fax, 6, 8, 12
Genio Suite, 8–9 M
product documentation, 4–5
Professional Services, 7–8 mailing files, 169–170
Sales, 12 MAPI, 169–170
Technical Support, 5–6 MAXIMUM function, 50
World Wide Web address, 8, 12 message pane, super query window, 138
MINIMUM function, 50
Modifiers command, 88, 89, 92
I More Windows command, 139
multi-level prompts, 97, 98–106
importing multiple prompts, 97, 98–106
data values, 89
results, 89–90
prompts, 106–107 N
results from another application, 89–90
variables, 116–117 names of
Insert DB Name command, 121 data values files, 85–86
Insert Subquery command, 123 prompts, 97, 99, 100
invalid data entry, 73 natural joins, 133–136
Negate Clause command, 40
negating qualifications, 40
J nested queries, 122–124
New Query command, 144
Join command, 135 none function, 50
join conditions, 143 null values, 46, 51
joining columns of results, 132–136 numbers
entering, 71–73
formats, 71–73, 76
L
leaving prompts empty, 38 O
linking
data objects, 142–144 objects. See data objects, buttons, ornaments, and
data values to relationships
attributes, 85–86 OLAP (Online Analytical Processing), 10, 11
prompts, 85–86, 103

Index 175
online preferences
documents, 4 Allow Dynamic Relationships, 143
Help, 5 Case-sensitive Comparisons, 33
technical support, 6 Show Relationship Names, 16
tool tips, 5 Show Relationships, 16
opening data models, 23 Show SQL String, 125
operations problems, reporting, 6
append, 130–132 procedures, in variables, 108
editing, 139–140 product support, 5–6
join, 132–136 Professional Services, Hummingbird, 7–8
range, 128–129 Prompts command, 97, 100, 106
super query window, using, 137 Prompts file, 108
operator list, 34, 42–64 prompts, 37–38, 96–107
operators, 34, 42–64, 124 conditional, 97, 101–106
comparisons, making, 43–44 creating, 97, 99–100, 102
in variables, 108 data values, using with, 85–86, 103
matching drill-down, 97, 98–106
character strings, 44–45 files, 97
items in list, 45 group, 97, 98–106
null values, 46 hierarchical, 97, 98–106
range of values, 45–46 importing, 106–107
user-defined, 46 leaving empty, 38
options for exporting results, 160 multiple, 97, 98–106
order of names, 97, 99, 100
attributes, 60–63 qualifying
columns in results, 58, 130 actual relationships, 96
prompts, 99 attributes, 54, 96, 136
ordering columns, 58–59 data objects, 96
ornaments, split data models with, 24 single, 97, 97–98
outer joins, 133–136 testing, 100, 104–106
titles, 100
publishing queries. See BI/Broker Publishing and Scheduling
P Guide

Paste Query from Model command, 139


permissions Q
Cache Passwords, 26
Dynamic Relationships, 143 qualification text box, 33
Edit Queries, 125 qualification tree, 32–35, 53
Save Queries, 65, 155 condition box, 35, 39–40, 42
placeholders, in variables, 111–113 data values icon, 34–37
Preferences command, 16, 72, 160 list icon, 33

176 Index
operator list, 34, 42–64 editing, 125–126
qualification text box, 33 correcting errors, 140–142
qualifying exporting, 155–156, 169–170
actual relationships, 96 files, 68
attributes, 30–47, 53–54 filtering, range, 128–129
ad hoc drill-down mode, 126–128 mailing, 169–170
combining qualifications, 35, 41–42 nested queries, 122–124
comparisons, making, 43–44 ordering columns, 58–59
deleting, 35 prompts. See prompts
editing qualifications, 125–126 publishing. See BI/Broker Publishing and Scheduling
grouping, 47–57 Guide
matching character strings, 44–45 retrieving. See BI/Broker Publishing and Scheduling
matching items in list, 45 Guide
negate clause, 35, 39 saving, 64–66, 155–156
null values, 46 scheduling. See BI/Broker Publishing and Scheduling
operators, 34, 42–64, 124 Guide
qualification tree, 32–35 securing. See BI/Broker Publishing and Scheduling Guide
range of values, 45–46 sort order, 60–63
reversing qualifications, 35, 39 sorting rows, 60–63
separating combined qualifications, 42 SQL. See SQL
with an attribute, 54, 121–122 standard, 133, 155
with data values, 34, 35–36, 83–96 submitting,
with multiple qualifications, 40 to applications, 156–169
with prompts, 37–38, 54, 85–86, 96–106 to files, 68
with subqueries, 122–124 subqueries, 122–124
with values, 33 super, 91
with variables, 38–39, 115 variables. See variables
data objects, 96
results, 126–128
Queries folder, 65, 97 R
queries, 17–18, 29–38
building, 17 Range command, 129
calculations with, 47–57 range, results in, 45–46, 128–129
circular, 144–151 Relationship command, 143
no correlations, 149–151 relationships, 16
with correlations, 145–149 creating, 142–144
combining, 136 dynamic, 142–144
append, 130–132 saving, 143
join, 132–136 reporting problems, 6
complex, 129 reports
creating, 17 creating. See BI/Query Reports Guide 65
combining, 136 exporting, 170

Index 177
reports (continued) running BI/Query, 21
mailing, 169–170
repository, 10
restricting S
queries. See qualifying attributes
results, 144–151 Sales, Hummingbird, 12
results Save Queries permission, 65, 155
columns Save Query command, 65, 92, 123, 139, 141, 155
hiding, 130 Save Results command, 68, 157
joining, 132–136 saving
order, 58, 130 queries, 64–66, 155–156
ordering 58–59 relationships, 143
combining, 136 results, 67–68, 157
data formats, 71–79 SQL string, 155–156
data values. See data values scalar functions, 57
exporting, 67–68, 156–170 Scheduler, 10
files, 67–68 scheduling queries. See BI/Broker Publishing and Scheduling
format, 159 Guide
grouping, 54 Search for Help On command, 5
mailing, 169–170 Send command, 170
qualifying, 126–128 sending
range, specifying, 45–46, 128–129 mail, using, 169–170
restricting, 144–151 queries
restricting. See qualifying to applications, 156–169
retrieving. See queries to files, 68
rows separating
appending, 130–132 columns in reports, 131
sorting, 60–63 qualifications, 42
saving, 67–68, 157 separators, for exporting results, 160
sending Show Query command, 38, 125
to applications, 156–169 Show Super Query command, 128, 139, 140
to files, 68 single prompts, 97, 97–98
sorting 63 sliding dates, 73–75
values, substituting, 78–79 Sort Order command, 63
Results Options command, 90, 160 sorting rows, 60–63
retrieving information from the database. See queries split data models, 23
retrieving queries. See BI/Broker Publishing and Scheduling administrator layer, 24
Guide buttons, 24
reversing qualifications, 35, 39 ornaments, 24
rows reestablishing path between layers, 24
sorting, 60–63 splitter bar, super query window, 137
See also results spreadsheets, data values results files, 89–90

178 Index
SQL tool tips, 5
HAVING clause, 53–54 trace utility, 7
operators. See operators Tracing Enabled command, 7
string tree list, super query window, 137
editing, 125–126 triggers, 78–79
limit, 126 Trim Relationships command, 149
saving, 155–156 troubleshooting problems, 7
WHERE clause, 53 two-digit years, converting, 73–75
standard queries, 155
saving, 64–65
starting BI/Query, 21 U
strings, computed, 78–79
Submit Query — To File command, 68, 157 Uncombine command, 42
Submit Query command, 139, 149, 151 User and Group Manager, 10
submitting queries user-layer files, 23
to applications, 156–169 user-defined
to files, 68 attributes, 55–57
subqueries, 122–124 calculations, 51
in variables, 108 operators, 46
substituting values, 78–79 utilities, trace, 7
SUM DISTINCT function, 50
SUM function, 47, 48, 50, 52
summary information. See aggregate functions V
super queries, 91, 129
See also filtering and combining queries Variables command, 109, 116
super query window, 137–138, 139, 140 variables, 38–39, 107–117
suppressing duplicate information, 50 calculating
dates, 107
time, 107
T containing
attributes, 110–113
tables in database, representing, 15 functions, 113–114
technical support, 5–6 operators, 110–113
contacting, 6 placeholders, 110–113
using the trace utility, 7 prompts, 115
Teradata database, 55 variables, 114–115
testing prompts, 100, 104–106 creating, 108–115
text editor, for data values results files, 89–90 importing, 116–117
time qualifying attributes, 107–115
calculating in variables, 107
including in results, 77
titles in prompts, 100

Index 179
W
WHERE clause, 53
displaying prompt values, 38
in variables, 38–39, 108
WinCLI connections, 55
windows, appearance in this guide, 4
working offline, 21
World Wide Web
Hummingbird address, 8, 12

Y
Year-2000 compliance, 73–75

180 Index

You might also like