Remove duplicate row from SQL results

This is my SQL query to get result from ORACLE DB

SELECT U."UID", 
CONCAT(CONCAT(U.LNAME, ', '), U.FNAME) AS UNAME,
M.NAME,
(SELECT COUNT(LH."UID") FROM DRUPAL_SYS.LOGIN_HISTORY LH WHERE LH."UID"=U."UID" ) AS VIEWS_COUNT,
L.LOGIN as "ACCESS" FROM DRUPAL_SYS.USERS U INNER JOIN DRUPAL_SYS.LOGIN_HISTORY L ON L."UID" = U."UID"
INNER JOIN ABC_WEBAPP.MEMBER_USER_ROLE MUR ON MUR.USER_ID=U.MDES_ID AND MUR.MEMBER_ID LIKE '%' 
INNER JOIN ABC_WEBAPP.MEMBER M ON M.ID=MUR.MEMBER_ID WHERE U.LOGIN != 0 AND U."UID">1 ORDER BY L."LOGIN" ASC`

Its giving a result with duplicate names

enter image description here

But my expected result should be like

enter image description here


Source: sql

Leave a Reply