0

一家公司可以有一个或多个报价 一个报价有多个工作

所以:公司 <= 提供 <= numJobs

SELECT Count(t_offer.fkCompany) AS companies, 
       Count(t_offer.id) AS offers, 
       Sum(t_offer.nJobs) AS numJobs
FROM t_offer

例如:

idOFFER    fkCOMPANY     numJOBS
   1           1            1
   2           3            2
   3           8            1
   4           1            2

查询应该是:

公司(3) <= 报价(4) <= numJobs(6)

但结果是:

公司(4) <= 报价(4) <= numJobs(6)

是通过多个查询来做到这一点的唯一方法吗?

4

1 回答 1

1

我想你想要不同公司的数量?

SELECT Count(DISTINCT t_offer.fkCompany) AS companies, 
       Count(t_offer.id) AS offers, 
       Sum(t_offer.nJobs) AS numJobs
FROM t_offer
于 2012-04-20T11:19:20.617 回答