数据库查询问题-sql 语句

需要查询出table1数据 包含总行数,和fName在table2(fPosition)中存在的数量 怎么将下面两个查询整合到一起

查询table1表中(fName)在table2(fPosition)中存在的数量
    SELECT
    b1.fName,
    COUNT (b2.fPosition) AS instnum
FROM
    table1 b1
LEFT JOIN table2 b2 ON b1.fName = b2.fPosition
GROUP BY
    b1.fName

分页查询
    SELECT
        TOP ${pagesize} *
    FROM
        (
            SELECT
                row_number () OVER (ORDER BY fID) rownumber,
                COUNT (1) OVER () AS TotalCount ,*
            FROM
                table1
            WHERE
            fPlatformID = #{fplatformID}
        ) a
    WHERE
    rownumber > ${pagenum}

https://blog.csdn.net/junjunba2689/article/details/79450171

with cte_a as (
 SELECT
                row_number () OVER (ORDER BY fID) rownumber,
                COUNT (1) OVER () AS TotalCount ,*
            FROM
                table1
)
,cte_b as (
SELECT
    b1.fName,
    COUNT (b2.fPosition) AS instnum
FROM
    table1 b1
LEFT JOIN table2 b2 ON b1.fName = b2.fPosition
GROUP BY
    b1.fName
)
select a.*,b.instnum from cte_a a 
left join cte_b b
on a.fName=b.fName

用union all就行