select orders.orderid,order_details.productid,products.productname,order_details.unitprice,order_details.quantity,order_details.unitprice*order_details.quantityas Total
from order_details,orders,products
where orders.orderid=order_details.orderid
And Products.productID=order_details.productID
and order_details.orderid in (
select orderid from Order_details group by orderid having count( distinct productid)<3
)Order Details 用 [Order Details]

解决方案 »

  1.   

    谢谢!你的代码有一些小错误,我修改了一下:select orders.orderid,order_details.productid,Orders.customerid,customers.companyname,products.productname,order_details.unitprice,order_details.quantity,(order_details.unitprice*order_details.quantity)as Total
    from order_details,orders,products,customers
    where orders.orderid=order_details.orderid
    And Products.productID=order_details.productID
    and Orders.customerid=customers.customerid
    and order_details.orderid in (
    select orderid from Order_details group by orderid having count( distinct productid)<3)
    order by orders.orderid