if we have table id, name, age
the requirements is id has different and redundatnt data
We want the distinct column with corresponding rows. this is highly useful
SELECT id,
role_id_fk,
privilege_id_fk
FROM (SELECT id,
role_id_fk,
privilege_id_fk,
Row_number() OVER(PARTITION BY role_id_fk ORDER BY id) rn
FROM tbl_roles_privileges) t
WHERE rn = 1
No comments:
Post a Comment