Hitachi

Hitachi Advanced Database SQL Reference


1.5.2 Example 2: Retrieve data conditioned on date of purchase and product code

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 P002 on September 6, 2011 or later.

Table to search

[Figure]

Specification example
SELECT "USERID","PUR-CODE","PUR-DATE"
    FROM "SALESLIST"
        WHERE "PUR-DATE">=DATE'2011-09-06'
        AND "PUR-CODE"='P002'
Retrieval results

[Figure]

Note

The WHERE clause specifies the following two search conditions connected by AND.

  • Purchase of a product on or after September 6, 2011

  • Purchase of a product whose product code is P002