PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
A select query (corresponding SQL statement SELECT) is used to view a selection of records in 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),
  • the selection conditions of records (customers who live in Seattle, products whose price is greater than 40 Dollars, ...),
  • the grouping of item values (grouping the products by type, the customers by age, ...),
  • the operations performed on the content of items (total amount of orders for a customer, average sum spent per customer, ...),
  • the sort of query result (result sorted by zip code, by price, ...).
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. Display the popup menu of 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, 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 among 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).
    Go 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.
    See Items taking part in a query for more details.
  8. In the middle section, select the query in which an action must be performed (selection condition, sort, 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 the 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" pane, 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 among 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".
    Go 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.
    Go 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.
    See Items taking part in a query for more details.
    Go 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 (equal to, greater than, ...) of the condition. This condition can be applied to a given value, a parameter, the records selected by another query, ...
      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 modify the characteristics of a query, go to the "Query" pane, "Edit" group and click "Description". See Describing a query for more details.
  • To generate the SQL code corresponding to this query, select "SQL code" from the popup menu of the query. If changes are made in the query description, these changes will be automatically carried over into 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