Entering content frame

Background documentation Data Query Locate the document in its SAP Library structure

A full description of the syntax used in the SQL statements for data queries is provided under Data Query in the Reference Manual.

The following section uses examples to explain a few of the key SQL statements for data queries.

Prerequisites

You need the HOTELDB_SIMPLE version of the model database HOTELDB.

Start the SQL Studio query tool as the database administrator MONA with the password RED.

Example of a Data Query

SELECT zip, name, state
  FROM city
    WHERE name = 'Washington'

This means:

·        Find (SELECT)

·        The columns zip, name, state

·        From the table city (FROM)

·        For the rows with the city name Washington (WHERE)

A simple SELECT statement, therefore, is structured as follows:

SELECT.....

FROM.......

WHERE......

Result

ZIP

NAME

STATE

20005

Washington

DC

20019

Washington

DC

20037

Washington

DC

Examples

·        Selecting, Arranging, and Renaming Columns

·        Selecting and Arranging Rows

·        Conditions: Comparison, AND, OR, BETWEEN, IN

·        Searching for Character Strings: LIKE

·        Negative Conditions: NOT

·        Creating Groups: GROUP BY, HAVING

·        Arithmetic Operations

·        Functions

·        Set Functions

·        Date and Time Calculations

·        Converting Values

·        Changing Character Strings

·        Information About Character Strings

·        Subquery: Internal Queries

·        Joins: Information From Several Tables

·        Set Operations: UNION, INTERSECT, EXCEPT

 

Leaving content frame