13.07.2015 Views

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

5. ADVANCED QUERY5.1 OverviewThe steps for creating "Simple" queries have been explained in the previous chapters. The query editor canalso be used to create some advanced queries. You have the ability to:• use the query result in another query. This is the concept of sub-queries.• use parameters in a query. The value of these parameters will be specified when the query is run. Thisis the concept of query with parameters.5.2 Sub-queryA sub-query is a query whose result is used by another query.For example, you want to select the orders whose total sales amount is greater than the average salesamount for orders. The average order amount is not known directly. This average amount will be returned byanother query (called sub-query).A sub-query can be used:• as selection condition,• as data source for the main query.Limits:• The sub-queries cannot be created in the query editor.• The ORDER BY statement is not allowed in the sub-queries5.2.1 Sub-query as selection conditionA sub-query can be used as selection condition.The authorized syntaxes are as follows:SELECT Item1 [, Item2]FROM File1 [, File2]WHERE [NOT] EXISTS (SELECT Item1[, Item2]FROM File1 [, File2][WHERE …])SELECT Item1 [, Item2]FROM File1 [, File2]WHERE Item1 Operator (SELECT Item1[, Item2]FROM File1 [, File2][WHERE …])In this syntax, can correspond to:• ALL, ANY, IN, NOT IN or SOME.• a <strong>com</strong>parison operator (=, =, or !=).• the <strong>com</strong>bination of ALL, ANY or SOME and a <strong>com</strong>parison operator (=, =, or !=).212Part 2: Query editor

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

Saved successfully!

Ooh no, something went wrong!