【问题标题】:average length of characters mysql compared to length of namemysql的平均字符长度与名称长度的比较
【发布时间】:2020-04-02 14:41:05
【问题描述】:

我需要将列名的平均长度与每个名称进行比较,如果名称有更多字符,我需要显示该名称... 谁能帮帮我?

WHERE length(naam) > sum(length(naam)/count(naam);
WHERE length(naam) > (sum(length(naam)/count(naam));
WHERE length(naam) > avg(length(naam)

上述方法不起作用,但也许它让您对可能的解决方案有所了解

【问题讨论】:

  • 您是否在给定列“naam”内寻找比该列的平均长度更长的值?我无法区分您所说的 column 自己的 name 和 column 中保存的值。

标签: mysql database compare average string-length


【解决方案1】:

WHERE 子句中使用返回列名平均长度的子查询:

SELECT * FROM tablename
WHERE length(naam) > (SELECT AVG(length(naam)) FROM tablename);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多