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.

32 Creating and Opening Files Chapter 2<br />

Importing Data<br />

When evaluating conditions, NOT statements are processed for the entire statement first, followed by<br />

AND statements, and then OR statements. Therefore<br />

SELECT * FROM Solubil WHERE ETH > -2 OR OCT < 1 AND CCL4 > 0<br />

is equivalent to<br />

SELECT * FROM Solubil WHERE ETH > -2 OR (OCT < 1 AND CCL4 > 0)<br />

Using the IN and BETWEEN Statements<br />

To specify a range of values to fetch, use the IN and BETWEEN statements in conjunction with WHERE.<br />

IN statements specify a list of values and BETWEEN lets you specify a range of values. For example,<br />

SELECT * FROM Solubil WHERE LABEL IN (‘Methanol’, ‘Ethanol’, ‘Propanol’)<br />

fetches all rows that have values of the LABEL column Methanol, Ethanol, or Propanol.<br />

SELECT * FROM Solubil WHERE ETH BETWEEN 0 AND 2<br />

fetches all rows that have ETH values between 0 and 2.<br />

Using the LIKE Statement<br />

With the LIKE statement, you can select values similar to a given string. Use % to represent a string of<br />

characters that can take on any value. For example, you might want to select chemicals out of the<br />

Solubil data that are alcohols, that is, have the –ol ending. The following SQL statement accomplishes<br />

this task.<br />

SELECT * FROM Solubil WHERE LABELS LIKE ‘%OL’<br />

The % operator can be placed anywhere in the LIKE statement. The following example extracts all rows<br />

that have labels starting with M and ending in OL:<br />

SELECT * FROM Solubil WHERE LABELS LIKE ‘M%OL’<br />

Using Aggregate Functions<br />

Aggregate functions are used to fetch summaries of data rather than the data itself. Use any of the<br />

following aggregate functions in a SELECT statement.<br />

Table 2.3 SELECT Statement Functions<br />

Function<br />

Meaning<br />

SUM( )<br />

Sum of the column<br />

AVG( )<br />

Average of the column<br />

MAX( )<br />

Maximum of the column<br />

MIN( )<br />

Minimum of the column<br />

COUNT( )<br />

Number of rows in the column<br />

Some examples include:<br />

• The following statement requests the sum of the ETH and OCT columns:<br />

SELECT SUM(ETH), SUM(OCT) FROM Solubil<br />

• This statement returns the number of rows that have ETH values greater than one:<br />

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

• The following statement lets you know the average OCT value for the data that are alcohols:

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

Saved successfully!

Ooh no, something went wrong!