Hitachi

Hitachi Advanced Database SQL Reference


1.5.3 Example 3: Retrieve data conditioned on date of purchase and two product codes

Retrieve the customer ID (USERID), product code (PUR-CODE), and date of purchase (PUR-DATE) from the sales history table (SALESLIST) for customers who purchased a product whose product code is P001 or P003 on September 4, 2011 or later.

Table to search

[Figure]

Specification example
SELECT "USERID","PUR-CODE","PUR-DATE"
    FROM "SALESLIST"
        WHERE "PUR-DATE">=DATE'2011-09-04'
        AND ("PUR-CODE"='P001' OR "PUR-CODE"='P003')
Retrieval results

[Figure]

Note

If both AND and OR are specified, AND is evaluated first. To change the priority of evaluation, specify ( ) as in the specification example above.