如何显示超过3个“出价”的所有“文章”?

时间:2016-12-01 21:05:33

标签: sql join group-by oracle-sqldeveloper where

我想要显示超过3个“出价”的所有“优惠”的“ArticleName”。应输出“出价”的数量。

我不知道怎么写下来。但我想我知道逻辑。它应该计算表“bid”和“OID”列的相同数字,最后它应该粘贴超过3的数字。

照片:  More information about the structure of the tables "offer" and "bid". Also a "Expected result" which is shown the result. <-- really Important

2 个答案:

答案 0 :(得分:0)

SELECT * FROM (
    SELECT o.ArticleName, count(b.BID) as numberOfBids
    FROM Offer as o INNER JOIN bid as b ON o.oid = b.oid
    GROUP BY o.ArticleName
) as c
WHERE c.numberOfBids > 3

答案 1 :(得分:0)

这很容易:

Select ArticleName
     , count(*) NumberOfBids
  from Offer o
  join Bid b
    on b.oid = o.oid
 group by ARticleName
having count(*) >= 3