Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
FROM STOCKS. STOCK WHERE ITMNO < 120
[Figure: Example of deleting duplicate rows and fetching data]
DISTINCT is used to form one row from fetched rows containing equal values. DISTINCT can easily be used
incorrectly if the user does not realize that multiple rows will be fetched, which will result in an error. The following is
an example of using DISTINCT incorrectly:
Example 2:
In this example, DISTINCT is used incorrectly. PRODUCT and STOCKQTY are obtained from the
STOCK table for products for which ITMNO is less than "120".
SELECT DISTINCT PRODUCT, STOCKQTY INTO :PRODUCT, :STOCKQTY
FROM STOCKS. STOCK WHERE ITMNO < 120
13