我正试图在网上的练习页上用下表找出这个问题:
问题:
对于同一客户对同一产品进行评级的所有情况
不止一次,而且在某个时间点给予了较低的评价
比以前,返回客户名称,产品名称,
以及最低的星级。
我似乎不明白为什么这不正确-有人能帮忙吗?

最佳答案

以下是我目前所掌握的(没有样本数据):

SELECT
    Customer.customer_name,
    Product.product_name,
    MIN(Rating.rating_stars)
FROM Rating
JOIN Product ON Rating.prod_id = Product.prod_id
JOIN Customer ON Rating.cust_id = Customer.prod_id
GROUP BY Customer.customer_name, Product.product_name
HAVING COUNT(Product.prod_id) > 1

关于mysql - MySQL嵌套选择,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33780935/

10-15 19:40