You can use the ROW_NUMBER()
function like this:
SELECT *
FROM(SELECT workflowid, salesRepId, quantityAssigned,
quantityLeft, month, year
, ROW_NUMBER()
OVER (PARTITION BY salesRepId
ORDER BY workflowid) AS rownumber
FROM sm_salesRepWorkflow)
WHERE rownumber = 1;
Fiddle Demo
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…