求DB2 SQL脚本一个
有一个明细表,CustomerId,ProductId,Quantity,每个客户都有几种商品,每个客户的商品不同。现在需要为每个客户插入不在这张表中的所有商品的记录,记录的Quantity值为0。
也就是先distinct ProductId,然后distinct CustomerId,循环每个CustomerId,如果distinct ProductId的值不在这个CustomerId的商品中,就为这个CustomerId加入Quantity为0的商品记录。
这个用一个临时表和一个游标能够解决,但是由于不懂DB2脚本,还望高手指教。