Finding the distinct record from sql server
I need to get the records from 2 tables procedure and procedure_user_map,
i am writing a query in sql sever in order to get the records based on the
limit and offset which is selected from ui, i am writing the following
query in order to get the records
but i am not getting 10 records the rownum() function is not working after
finding distinct instead it is putting count on the each row
WITH MD_Results AS
(
SELECT P.pk, P.procedure_name,
RowNum() OVER (order by P.procedure_name asc) AS RowNum
FROM "procedure" P, "procedure_user_map" PUM
where P.pk = PUM.procedure_fk
)
SELECT DISTINCT "pk", "procedure_name", RowNum FROM MD_Results
WHERE RowNum > 0 AND RowNum <= 0 + 10
I want to get the distinct records of procedure and do a rownum() over
that to get the count correct
No comments:
Post a Comment