如何根据某些值的出现对值进行排序?

发布于 2024-10-09 02:04:30 字数 257 浏览 0 评论 0原文

我有下表:

| Jon | "a" |
| Eva | "b" |
| Jon | "a" |
| Eva | "a" |
| Eva | "b" |

我想从第一列(名称)中获取按行数排序的唯一值,其中(对于所考虑的名称)第二列的值“a”除以包含所考虑名称的列数。

例如,对于 Eva,带有“a”的行数为 1,带有 Eva 的总列数为 3。因此,排序参数将等于 0.33(3)。

任何人都可以帮我吗?

I have the following table:

| Jon | "a" |
| Eva | "b" |
| Jon | "a" |
| Eva | "a" |
| Eva | "b" |

I would like to get unique values from the first column (names) ordered by number of rows where (for the considered name) the second column has value "a" divided by the number of columns containing the considered name.

For example for Eva the number of rows with "a" is 1, and total number of columns with Eva is 3. So, the parameter for the ordering will be equal 0.33(3).

Can anybody, pleas, help me with that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖果控 2024-10-16 02:04:30
SELECT  name
FROM    mytable
GROUP BY
        name
ORDER BY
        SUM(letter = 'a') / COUNT(*)
SELECT  name
FROM    mytable
GROUP BY
        name
ORDER BY
        SUM(letter = 'a') / COUNT(*)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文