1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/按分类统计薪水 [count-salary-categories].html
2023-12-09 18:53:53 +08:00

59 lines
1.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>表: <code>Accounts</code></p>
<pre>
+-------------+------+
| 列名 | 类型 |
+-------------+------+
| account_id | int |
| income | int |
+-------------+------+
在 SQL 中account_id&nbsp;是这个表的主键。
每一行都包含一个银行帐户的月收入的信息。
</pre>
<p>&nbsp;</p>
<p>查询每个工资类别的银行账户数量。&nbsp;工资类别如下:</p>
<ul>
<li><code>"Low Salary"</code>:所有工资 <strong>严格低于</strong> <code>20000</code> 美元。</li>
<li><code>"Average Salary"</code> <strong>包含</strong> 范围内的所有工资&nbsp;<code>[$20000,&nbsp;$50000]</code></li>
<li>
<p><code>"High Salary"</code>:所有工资 <strong>严格大于</strong> <code>50000</code> 美元。</p>
</li>
</ul>
<p>结果表 <strong>必须</strong> 包含所有三个类别。&nbsp;如果某个类别中没有帐户,则报告&nbsp;<code>0</code></p>
<p><strong>任意顺序</strong> 返回结果表。</p>
<p>查询结果格式如下示例。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>
Accounts 表:
+------------+--------+
| account_id | income |
+------------+--------+
| 3 | 108939 |
| 2 | 12747 |
| 8 | 87709 |
| 6 | 91796 |
+------------+--------+
<strong>输出:</strong>
+----------------+----------------+
| category | accounts_count |
+----------------+----------------+
| Low Salary | 1 |
| Average Salary | 0 |
| High Salary | 3 |
+----------------+----------------+
<strong>解释:</strong>
低薪: 有一个账户 2.
中等薪水: 没有.
高薪: 有三个账户,他们是 3, 6和 8.</pre>