简单做一个记录。

SELECT COUNT(item_id) FROM 59_dormitem ;#126951
SELECT SUM(temp.sum_rid) 
    FROM 
    (SELECT 
        dorm_id,
        COUNT(rid) sum_rid 
    FROM 
        59_dormitem 
    GROUP BY dorm_id)temp;
    # 126951