1

これら2つの類似したクエリを1つのクエリに結合する必要があります

1.1。

SELECT avg(size) 
FROM (
    SELECT  size,addr,sha1 
    FROM data WHERE id >= (abs(random()) % (SELECT max(id) FROM data)) LIMIT 8000
);

2.2。

SELECT sum(size2 * cnt), sum(cnt)  
FROM (
    SELECT size as size2, sha1, COUNT (*) as cnt 
    FROM 
        (
        SELECT size,addr,sha1 
        FROM data 
        WHERE 
            id >= (abs(random()) % (SELECT max(id) FROM data)) LIMIT 8000
        ) 
    GROUP BY sha1, size 
    HAVING count(*)>=2
    );

私はこれを好きにしようとしますが、それは正しくないかもしれません。

SELECT sum(size2 * cnt), sum(cnt),  avg(sizeavg) 
FROM 
    (
    SELECT sizeavg, size as size2, sha1, COUNT (*) as cnt 
    FROM 
        (
        SELECT size, size as sizeavg,addr,sha1 
        FROM data 
        WHERE id >= (abs(random()) % (SELECT max(id) FROM data)) 
        LIMIT 8000
        ) 
    GROUP BY sha1, size 
    HAVING count(*)>=2
);
4

0 に答える 0