Hitachi

Hitachi Advanced Database SQL Reference


1.5.1 Example 1: Retrieve data conditioned on date of purchase

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 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'
Retrieval results

[Figure]

Note
  • When specifying search conditions in the WHERE clause, you can use the comparison operators listed below. The following table lists the comparison operators and their meanings.

    Table 1‒1: Comparison operators and their meanings

    No.

    Comparison operator

    Meaning

    1

    =

    equal to

    2

    <>, !=, or ^=

    not equal to

    3

    <

    less than

    4

    <=

    less than or equal to

    5

    >

    greater than

    6

    >=

    greater than or equal to

  • If the value specified in the conditional expression is a CHAR type or VARCHAR type character string, enclose the value in single quotation marks (').

    Example: WHERE "NAME"='Taro Tanaka'

  • If the value specified in the conditional expression is a date of type DATE, specify it in the following manner.

    Example: WHERE "PUR-DATE">=DATE'2011-09-06'