The Select element is the only mandatory element in a query. In the Select statement, you specify the table and field names. Here you select the table and fields that you want to display. In the example we want to display the document number, business partner code, business partner name and total amount from the Purchase Order table OPOR.
If we just wanted to see every field in the table we could use the asterisk character, instead of selecting individual field names. However, most tables can contain hundreds of fields, so you usually need to select the individual fields.
When the query runs, headings for the report columns are taken from the database column names, but you can change these in SQL using the “as” keyword and entering the heading name in quotes. For example, to change the column heading for the DocTotal field, you Select DocTotal as “Total Amount”.
You can also specify calculation fields that display the result of an addition, subtraction, multiplication, or division of two fields.
If you need more than one table for a query, you normally need to create relationships between them. The Query Wizard and Query Generator tools make this easy for you by automatically creating joins. For example, if you select the purchase orders table (OPOR) and also select the business partners master data table (OCRD), the query tools will link these tables using the business partner code.