SELECT M.*,S.NAME SERVERNAME,W.Name WARENAME from m_system_desktopapp M,base_server S,base_ware
W
WHERE M.SERVERID=S.ID(+) and ((s.status = 1 and s.is_deleted = 0) or s.id is null) AND M.WAREID=W.ID(+) and
((w.state = 1) or w.id is null)
order by M.displayorder