i select last_name percent from families table with round function ..my query is :
SELECT F.family_id, F.last_name
FROM
(SELECT family_id, father_name, last_name, economic_state, father_state,
ROW_NUMBER() OVER (PARTITION BY last_name
ORDER BY last_name, economic_state DESC) RowNo
FROM FamiliesForCalculationShare
WHERE economic_state = 'a' OR economic_state = 'b') F INNER JOIN
(SELECT last_name, Count(1) AS FamCount FROM FamiliesForCalculationShare
GROUP BY last_name) GR ON F.last_name = GR.last_name AND
f.rowno <= round(GR.FamCount * 40 / 100., 0)
the problem is i have one family that has one last name ..and when the percent be 40 % or 30% ... the round function make it 0.4 or 0.3 for this one family and don't select it .. but i need round function for other families and want to select this one family .. so i need if (family_lastname_count = 1 ) select it whatever percent is .