1.有如下表
1.写出一条SQL语句,查询红色数量比蓝色多的产品及数量差额。
SELECT a.product ,(a.h-b.h)'差额' from (SELECT sum(num)h, product from test1 GROUP BY product,color having color='红色')a, (SELECT sum(num)h, product from test1 GROUP BY product,color having color='绿色')b where a.h>b.h and a.product=b.product