mainframe - DB2- fetching records having products in more than one store -


I have a table in which the record is down

store number product number.

0001 11

0002 11

0003 11

0001 12

0002 12

< P> 0001 13

I want to get records containing products in more than one store. The result should be as follows

Store number product number.

0001 11

0002 11

0003 11

<

0001 12

0002 12

The last record should not be there because the product is only in one store.

Please help?

I'm going to call you 'availability' table, I did the following with postgresql, but this Standard SQL, and I believe that DB2 has excellent support for standard SQL, and will handle them properly.

The way I feel most natural here:

  Select from availability * where product_no (select product_no from product_no from the availability group (*) > 1);  

If you prefer it as a correlated subquery:

 Select from  availability where one (select from availability (* ) * Product_no = a .product_no) & gt; 1;  

Comments