1

我正在使用 MySQL。

我正在尝试选择字段的最小、最大和平均长度,但我不确定如何。像这样的东西:

SELECT 
  min as min,
  max as max,
  avg as avg
FROM COLUMNS
WHERE COLUMN_NAME like '%password%'

有任何想法吗?

4

3 回答 3

7
select
    column_name,
    min(length(column_name)) as min,
    max(length(column_name)) as max,
    avg(length(column_name)) as avg
from columns
where column_name like '%password%'
group by column_name
于 2012-10-18T12:49:15.110 回答
2
SELECT Min(COLUMN_NAME), 
       Max(COLUMN_NAME), 
       Avg(COLUMN_NAME) 
  FROM TABLENAME 
 WHERE COLUMN_NAME LIKE '%password%' 
于 2012-10-18T12:51:27.137 回答
0
SELECT Min(MENTION_COLUMN_NAME_HERE) AS minimum_value, 
       Max(MENTION_COLUMN_NAME_HERE) AS maximum_value, 
       Avg(MENTION_COLUMN_NAME_HERE) AS average_value 
  FROM COLUMNS 
 WHERE COLUMN_NAME LIKE '%passord%' 
于 2012-10-18T12:52:54.103 回答