Hitachi

Hitachi Advanced Database SQL Reference


1.7.2 Example 2: Retrieve customers who purchased products except for a specific customer

Retrieve the customer ID (USERID), product code (PUR-CODE), and quantity purchased (PUR-NUM) from the sales history table (SALESLIST). At this time, skip retrieval for customers whose customer IDs (USERID) are U00212 and U00358.

Table to search

[Figure]

Specification example
SELECT "USERID","PUR-CODE","PUR-NUM"
    FROM "SALESLIST"
       WHERE "USERID" NOT IN ('U00212','U00358')
Retrieval results

[Figure]

Note

If NOT is specified, the search will return values that do not satisfy the conditional expression immediately following the NOT. If you specify NOT IN ('U00212','U00358'), as in the specification example above, the retrieval criteria will exclude customer IDs U00212 and U00358.