<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/tt/onlinemanual/100032" xml:lang="en">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">To define a query with Easy SQL</Title>
		<Keyword ContextSensitive="No"><Level1>Easy SQL</Level1>
			<Level2>defining a query</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>Queries</Level1>
			<Level2>defining with Easy SQL</Level2>
		</Keyword>
	</Header>
	<GeneralSection><ProcedureSection><ProcIntro><Paragraph class="Default">To define a query with Easy SQL, complete the following steps:</Paragraph>
			</ProcIntro>
			<Steps><Step><StepTitle>Specify basic query properties</StepTitle>
					<ProcedureList><ListItem>Start the <Link href="/baanerp/tt/adv/ttadv3580m000" role="session">Query Data (ttadv3580m000)</Link> session.</ListItem>
						<ListItem>Click <GUIRef href="/baanerp/stcommands/stcommands#stp_add.set" role="command">New</GUIRef>. The <GUIRef href="/baanerp/tt/adv/ttadv3180s000" role="session">Query Data (ttadv3180s000)</GUIRef> details session starts.</ListItem>
						<ListItem>Specify the basic properties of the <Link href="/baanerp/tt/glossary/glossary#100052" role="glossary">query</Link>, such as the owner and the output type. Select one of the following output types: <List><ListItem>Report list</ListItem>
								<ListItem>Report label</ListItem>
								<ListItem>Chart</ListItem>
							</List>
						</ListItem>
						<ListItem>To return to the <GUIRef href="/baanerp/tt/adv/ttadv3580m000" role="session">Query Data (ttadv3580m000)</GUIRef> overview session, click <GUIRef href="" role="manual">Save and Close</GUIRef>.</ListItem>
					</ProcedureList>
				</Step>
				<Step><StepTitle>Add table(s)</StepTitle>
					<ProcedureList><ListItem>In the <GUIRef href="/baanerp/tt/adv/ttadv3580m000" role="session">Query Data (ttadv3580m000)</GUIRef> session, select the new query and, on the <GUIRef href="" role="menu">Specific</GUIRef> menu, click <GUIRef href="/baanerp/tt/adv/ttadv3580m000#exec.user.2" role="command">Query By Easy SQL...</GUIRef>. The <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session starts.</ListItem>
						<ListItem>Click <GUIRef href="/baanerp/stcommands/stcommands#stp_add.set" role="command">New</GUIRef> and, from the <GUIRef href="/baanerp/tt/adv/ttadv3181m000#ttadv381.tabl" role="manual">Table</GUIRef> field, zoom to the <GUIRef href="/baanerp/tt/adv/ttadv3584m000" role="session">Display Tables (ttadv3584m000)</GUIRef> session.</ListItem>
						<ListItem>Find and select the relevant table, and click <GUIRef href="" role="manual">Save and Close</GUIRef>. The table is added in the <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session.</ListItem>
						<ListItem>In the <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session, press Tab.</ListItem>
						<ListItem>To add extra query tables, repeat steps 2, 3, and 4. Then, click <GUIRef href="/baanerp/stcommands/stcommands#stp_update.db" role="command">Save</GUIRef>.</ListItem>
					</ProcedureList>
					<ProcedureList><ListTitle>
                                          Note
                                       </ListTitle>
						<ListIntro>Optionally, you can add related tables through the <Link href="/baanerp/tt/adv/ttadv3581m000" role="session">Query Table Relationships (ttadv3581m000)</Link> session. To add related tables, complete the following steps:</ListIntro>
						<ListItem>In the <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session, select the table for which you want to add related tables.</ListItem>
						<ListItem>On the <GUIRef href="" role="menu">Specific</GUIRef> menu, click <GUIRef href="/baanerp/tt/adv/ttadv3181m000#exec.user.1" role="command">Add Related Tables</GUIRef>. The <Link href="/baanerp/tt/adv/ttadv3581m000" role="session">Query Table Relationships (ttadv3581m000)</Link> session starts.</ListItem>
						<ListItem>Select the relevant table(s) and click <GUIRef href="" role="manual">OK</GUIRef>.</ListItem>
					</ProcedureList>
					<Paragraph class="Default"></Paragraph>
				</Step>
				<Step><StepTitle>Add fields</StepTitle>
					<ProcedureList><ListItem>In the <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session, select the table record and, on the <GUIRef href="" role="menu">Specific</GUIRef> menu, click <GUIRef href="/baanerp/tt/adv/ttadv3181m000#exec.user.2" role="command">Add Table Fields</GUIRef>. The <GUIRef href="/baanerp/tt/adv/ttadv3582m000" role="session">Query Table Fields (ttadv3582m000)</GUIRef> session starts.</ListItem>
						<ListItem>Select the relevant field(s) and click <GUIRef href="" role="manual">OK</GUIRef>.</ListItem>
					</ProcedureList>
				</Step>
				<Step><StepTitle>Modify field properties</StepTitle>
					<ProcedureList><ListItem>In the <GUIRef href="/baanerp/tt/adv/ttadv3181m000" role="session">Query Table Data (ttadv3181m000)</GUIRef> session, select the table record and, on the <GUIRef href="" role="menu">Specific</GUIRef> menu, click <GUIRef href="/baanerp/tt/adv/ttadv3181m000#exec.user.3" role="command">Query Fields...</GUIRef>. The <GUIRef href="/baanerp/tt/adv/ttadv3182m000" role="session">Query Field Data (ttadv3182m000)</GUIRef> session starts.</ListItem>
						<ListItem>Double-click a query field. The <GUIRef href="/baanerp/tt/adv/ttadv3182s000" role="session">Query Field Data (ttadv3182s000)</GUIRef> details session starts. In this session, modify the print sequence, specify arguments, and so on.</ListItem>
						<ListItem>Repeat step 2 for each field.</ListItem>
						<ListItem>Save the changes and close the sessions.</ListItem>
					</ProcedureList>
				</Step>
				<Step><StepTitle>Generate query report</StepTitle>
					<Paragraph class="Default">Complete this step only if you selected <GUIRef href="/baanerp/tt/adv/ttadv3580m000#ttadv380.outp" role="manual">Output Type</GUIRef> Report list or Report label.</Paragraph>
					<ProcedureList><ListIntro>To generate the query report, complete the following steps:</ListIntro>
						<ListItem>Start the <GUIRef href="/baanerp/tt/adv/ttadv3580m000" role="session">Query Data (ttadv3580m000)</GUIRef> session.</ListItem>
						<ListItem>Select the query and, on the <GUIRef href="" role="menu">Specific</GUIRef> menu, click <GUIRef href="/baanerp/tt/adv/ttadv3580m000#exec.user.3" role="command">Generate Query Report</GUIRef>.</ListItem>
					</ProcedureList>
				</Step>
			</Steps>
		</ProcedureSection>
	</GeneralSection>
	<RelatedTopics><SectionTitle>
                              Related topics
                           </SectionTitle>
		<RelTopic><Link href="/baanerp/tt/onlinemanual/100036" role="manual">To add query table fields to a chart</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/onlinemanual/100021" role="manual">To run a query</Link>
		</RelTopic>
	</RelatedTopics>
</ManualTopic>
