SELECT
dsr.ChildOrderId,count(1) AS total,
100 * count(1)/sum(count(1)) OVER() AS pct,
sum(count(1)) OVER() AS Sumtotal,
ROW_NUMBER() OVER (ORDER BY count(1) DESC ) AS rn
FROM DX_SessionRecord AS dsr GROUP BY dsr.ChildOrderId
SELECT
dsr.ChildOrderId,count(1) AS total,
100 * count(1)/sum(count(1)) OVER() AS pct,
sum(count(1)) OVER() AS Sumtotal,
ROW_NUMBER() OVER (ORDER BY count(1) DESC ) AS rn
FROM DX_SessionRecord AS dsr GROUP BY dsr.ChildOrderId