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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example: The following SQL code is used to select the order number of the orders whose total amount isgreater than the average amount of all the orders:SELECT OrderNumFROM ORDERSWHERE Amount > (SELECT AVG(Amount)FROM ORDERS)5.2.2 Sub-query used as data source of a queryA sub-query can be used as file of the main query.The authorized syntax is as follows:SELECT Item1 [, Item2]FROM (SELECT Item1 FROM File1 [WHERE …])5.3 Query with parametersThe queries with parameters allow the user to easily select some records according to his own requirements.All he has to do is specify the parameters that must be taken into account.For example, a query with parameters can be used to select the orders placed by a specific customer. Theuser only has to select the name of the customer. The query will use this name in parameter.To include a query with parameters in a WinDev application, in a WinDev Mobile application or in a WebDevsite, you must:• create a query with parameters in the query editor.• modify the application or the site in order to run a query with parameters.The query with parameters can be used with a window, a Table control (looper, list box or <strong>com</strong>bo box),a report, …5.3.1 Creating a query with parametersRegardless of the query type (Select, Insert, Delete, Update) and regardless of its creation mode (with thewizard or by SQL directly), you have the ability to use parameters. The name of the parameter is specifiedwhen creating the query.To create a query with parameters:1. Create a query (see “How do I create a query?”, page 166 for more details).2. When defining the selection conditions:• specify that the selection condition corresponds to a parameter.• give the name of this parameter.See “Selection conditions”, page 196 for more details.5.3.2 Running the test of a query with parametersTo run the test of a query with parameters:1. Open the query with parameters in the query editor.2. Click to run the test of the query.3. Specify the value of the parameters that will be used to run the test of the query.Note: You can select a specific value via . The following menu is displayed:Part 2: Query editor 213

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

Saved successfully!

Ooh no, something went wrong!