ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Query editor / Creating queries
  • Overview
  • How to?
  • Creating a new select query with the description window of a select query
  • Creating a new Select query with the simplified wizard
  • Notes
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
A select query (SQL SELECT statement) is used to view a selection of records from a database. This is the most common type of query.
To perform this selection, the main query characteristics are as follows:
  • the type of join between the data files used (if several data files are used),
  • selection conditions are applied on records (customers who live in Seattle, products whose price is greater than 40 Dollars, etc.),
  • values from items are grouped (products grouped by type, customers grouped by age, etc.),
  • operations are performed on the content of items (total amount of the orders for a customer, average sum spent per customer, etc.),
  • the result of the query is sorted (by postal code, by price, etc.).
For example, you want to display the total amount of orders per customer living in London. Only the customers with a total amount of orders exceeding 3000 Dollars will be considered. The result will be sorted by total amount in ascending order. To perform this query, the result will be automatically grouped by customer name and by city.
Select query
The query editor automatically generates the SQL code of this query.
To see the SQL code of a query:
  1. Open the context menu of the query graph.
  2. Select "SQL code".
You also have the ability to press the F2 key.
SELECT
CUSTOMER.CustomerName AS CustomerName,
CUSTOMER.CITY AS CITY,
SUM(ORDERS.TotalIOT) AS the_sum_TotalIOT
FROM
CUSTOMER,
ORDERS
WHERE
CUSTOMER.CustomerNum = ORDERS.CustomerNum
AND
(
CUSTOMER.CITY = 'London'
)
GROUP BY
CUSTOMER.CustomerName,
CUSTOMER.CITY
HAVING
SUM(ORDERS.TotalIOT) > 3000
ORDER BY
the_sum_TotalIOT ASC
For more details on the description and use of a Select query, see:
How to?
Two methods can be used to create a select query:
  • creation via the description window of a select query.
  • creation via a simplified wizard.

Creating a new select query with the description window of a select query

To create a new select query with the description window of a select query:
  1. Click New in the quick access buttons.
    • In the window that is displayed, click "Query".
    • The query creation wizard starts.
  2. Specify that you want to create a select query ("Select" option).
    Proceed to the next step of the wizard.
  3. If your project is linked to no analysis, specify the analysis to which the query will be attached. Validate.
  4. The query description window appears.
  5. Type the query name (name of ".WDR" file corresponding to the query). This name will be used to identify the query in your programs.
  6. Specify the caption of the query by briefly describing the purpose of query. This caption will be used in the project documentation.
  7. In the left section, select the different items used by the query.
    Remark: To simplify the selection of items, these items can be displayed by associated data file, by associated query or in alphabetical order.
    For more details on the items of a query, see Items included in a query.
  8. In the middle section, select the item on which you want to perform an action (selection condition, sorting, etc.).
  9. In the right section, define the actions that must be performed on the selected item (selection condition, sort, etc.).
    For more details, see:
  10. Delete (if necessary) the "duplicate" records from the query result ("Delete duplicates" button).
    In this case, each record found in the query result will be unique. For example, if a query is used to display all customers who placed at least one order, the customers who placed several orders will appear once only in the query result.
  11. Validate the window. The graphic representation of the query is automatically displayed.
  12. On the "Home" tab, in the "General" group, expand "Save" and click "Save" to save the query.

Creating a new Select query with the simplified wizard

To create a new Select query with the simplified wizard:
  1. Click New in the quick access buttons.  In the window that appears, click "Query". The query creation wizard starts.
  2. Specify that you want to create a Select query ("Select" option), check "Use the simplified wizard".
    Proceed to the next step of the wizard.
  3. If your project is linked to no analysis, specify the analysis to which the query will be attached.
    Proceed to the next step of the wizard.
  4. Select the items used by the query.
    Remark: To simplify the selection of items, these items can be displayed by associated data file, by associated query or in alphabetical order.
    For more details on the items of a query, see Items included in a query.
    Proceed to the next step of the wizard.
  5. Select the order in which the items will be viewed. Go to the next step.
  6. Specify whether selection conditions must be described or not.
    Go to the next step.
    If selection conditions must be defined:
    • select the item for which a selection condition must be added.
    • choose the selection criteria for the condition (equal to, greater than, etc.). This condition can be applied to a given value, a parameter, the records selected by another query, etc.
      Repeat this step for all the selection conditions to define.
  7. Specify whether the elements selected by the query must be sorted or not.
    In this case, select the sort item and specify the sort order.
  8. Type the query name (name of ".WDR" file corresponding to the query). This name will be used to identify the query in your programs.
  9. Specify the caption of the query by briefly describing the purpose of query. This caption will be used in the project documentation.
    Remark: The query name is automatically defined from the caption typed.
  10. Validate the query description. The graphic representation of query is automatically displayed in the query editor.
Notes
  • To change the characteristics of a query, go to the "Query" tab, "Edit" group and click "Description". For more details, see Describing a query.
  • To generate the SQL code corresponding to this query, select "SQL code" in the context menu of the query. If changes are made in the query description, these changes will be automatically reflected in the corresponding SQL code.
  • You also have the ability to create a query from one or more data files described in the data model editor: to do so, drag the data files selected in the "Analysis" pane and drop them in the query editor.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/08/2023

Send a report | Local help