查询集限制SQL数据库


Name      Gender     School        Position     Salary
-----------------------------------------------------------
Alex      Male       Computing     Lecturer      $80,000
Bob       Male       Mathematics   Lecturer      $60,000
Carol     Female     Mathematics   Lecturer     $100,000
Diana     Female     Computing     Lecturer      $60,000
Ewen      Male       Physics       Lecturer      $72,000
Fran      Female     Physics       Lecturer      $88,000
Gary      Male       Computing     Administrator $40,000
Humphry   Male       Mathematics   Lecturer      $72,000
Ivana     Female     Computing     Tutor         $12,000
Je        Male       Physics       Administrator $80,000
Kim       Female     Mathematics   Lecturer     $100,000
Lex       Male       Computing     Tutor         $12,000
Morris    Male       Engineering   Tutor         $15,000    

假设您只有一个统计接口,因此只有聚合查询才会成功。你知道戴安娜是一名女性计算机讲师。下面的问题探讨了在存在各种查询大小限制的情况下,我们如何使用推理来确定她的薪水。

假设存在满足的查询大小上限和下限k jX(C)j N􀀀kk = 2。显示一系列可用于确定Diana薪水的查询。

这是一个学校的问题,有人能帮我吗?

一个聚合函数,有条件SUM()

 SELECT SUM(CASE WHEN Name = 'Diana' THEN Salary ELSE 0 END) as salary
 FROM YourTable

现在我不知道查询大小的下限是什么

SELECT Max(Salary)
FROM YourTable
WHERE School = 'computing'
  AND Gender = 'Female'
  AND Position = 'Lecturer'

相关内容

  • 没有找到相关文章

最新更新