I'm trying to modify a stored procedure hooked into an ORM tool. I want to add a few more rows based on a loop of some distinct values in a column. Here's the current SP:
SELECT
GRP = STAT_CD,
CODE = REASN_CD
FROM dbo.STATUS_TABLE WITH (NOLOCK)
Order by STAT_CD, SRT_ORDR
For each distinct STAT_CD, I'd also like to insert a REASN_CD of "--" here in the SP. However I'd like to do it before the order by so I can give them negative sort orders so they come in at the top of the list.
I'm getting tripped up on how to implement this. Does anyone know how to do this for each unique STAT_CD?