20.11.2015 Views

Data Mining Extensions - DMX - Reference

Create successful ePaper yourself

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

TOP and ORDER BY<br />

You can order the results of a query by using an expression, and can then return a subset<br />

of the results by using a combination of the ORDER BY and TOP clauses. This is useful in<br />

a scenario such as targeted mailing where you only want to send results to the most<br />

likely respondents. You could order the results of a target mailing prediction query by<br />

the prediction probability, and then only return the top results.<br />

Select List<br />

The can include scalar column references, prediction functions, and<br />

expressions. The options that are available depend on the algorithm, and the following<br />

contexts:<br />

• Whether you are querying a mining structure or a mining model<br />

• Whether you are querying content or cases<br />

• Whether source data is a relational table or a cube<br />

• If you are making predictions<br />

In many cases, you can use aliases, or create simple expressions based on the items in<br />

the select list. For example, the following example shows a simple expression on model<br />

columns:<br />

SELECT [CustomerID], [Last Name] + ', ' + [FirstName] AS FullName<br />

FROM .CASES<br />

The following example creates an alias for a column that contains the results of a<br />

prediction function:<br />

SELECT Predict([Column1], 'Value') as Column1Prediction<br />

FROM MyModel<br />

JOIN <br />

WHERE<br />

You can limit the cases that are returned by the query by using a WHERE clause. The<br />

WHERE clause specifies that column references in the WHERE expression must have the<br />

same semantics as column references in the of the SELECT statement, and<br />

can only return a Boolean expression. The syntax for the WHERE clause is as follows<br />

WHERE < condition expression ><br />

The select list and WHERE clause of a SELECT statement must follow the following rules:<br />

• The select list must contain an expression that does not return a Boolean result. You<br />

can modify the expression, but the expression must return non-Boolean results.<br />

• The WHERE clause must contain an expression that returns a Boolean result. You can<br />

modify the clause, but it must return a Boolean result.<br />

Predictions<br />

There are two types of syntax that you can use for creating predictions:<br />

62

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

Saved successfully!

Ooh no, something went wrong!