14.03.2014 Views

Download Jmp User Guide

Download Jmp User Guide

Download Jmp User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2 Creating and Opening Files 33<br />

Importing Data<br />

SELECT AVG(OCT) FROM Solubil WHERE LABELS LIKE ‘%OL’<br />

Note: When using aggregate functions, the column names in the resulting JMP data table are<br />

Expr1000, Expr1001, and so on. You’ll probably want to rename them after the fetch is completed.<br />

The GROUP BY and HAVING Commands<br />

The GROUP BY and HAVING commands are especially useful with the aggregate functions. They enable<br />

you to execute the aggregate function multiple times based on the value of a field in the data set.<br />

For example, you might want to count the number of records in the data table that have ETH=0,<br />

ETH=1, and so on, for each value of ETH.<br />

• SELECT COUNT(ETH) FROM Solubil GROUP BY (ETH) returns a single column of data, with<br />

each entry corresponding to one level of ETH.<br />

• SELECT COUNT(ETH) FROM Solubil GROUP BY (ETH) WHERE OCT > 0 does the same thing<br />

as the above statement, but only for rows where OCT > 0.<br />

When using GROUP BY with an aggregate function of a column, include the column itself in the<br />

SELECT statement. For example,<br />

SELECT ETH, COUNT(ETH) FROM Solubil GROUP BY (ETH)<br />

returns a column containing the levels of ETH in addition to the counts.<br />

2 Creating and Opening Files<br />

Using Subqueries<br />

Aggregate functions are also useful for computing values to use in a WHERE statement. For example, you<br />

might want to fetch all values that have greater-than-average values of ETH. In other words, you want to<br />

find the average value of ETH, and then select only those records that have values greater than this<br />

average. Remember that SELECT AVG(ETH) FROM Solubil fetches the average you are interested in.<br />

So, the appropriate SQL command uses this statement in the WHERE conditional:<br />

SELECT * FROM Solubil WHERE ETH > (SELECT AVG(ETH) FROM Solubil)<br />

Saving and Loading SQL Queries<br />

After constructing a query, you might want to repeat the query at a later time. You do not have to<br />

hand-type the query each time you want to use it. Instead, you can export the query to an external file.<br />

To do this, click the Export SQL button in the window shown in Figure 2.12. This brings up a window<br />

that lets you save your SQL query as a text file.<br />

To load a saved query, click the Import SQL button in the window shown in Figure 2.12. This brings<br />

up a window that lets you navigate to your saved query. When you open the query, it is loaded into the<br />

window.<br />

Using the WHERE Clause Editor<br />

JMP provides help building WHERE clauses for SQL queries during ODBC import. It provides a WHERE<br />

clause editor that helps you build basic expressions using common SQL features, allowing<br />

vendor-specific functions. For example, you do not need to know whether SQL uses ‘=’ or ‘==’ for<br />

comparison, or avg() or average() for averaging.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!