I have one query by which I am getting duplicate ComapnyID and I want to filter that and remove duplicate ComapnyID but don't want change the order by report.
table 1 reports
Table 2 Company
SELECT c.CompanyID,c.`CategoryID`,c.`CompanyName`, r.`CreatedDate`,r.`ReportID` FROM `company`c JOIN reports r ON r.CompanyID = c.CompanyID WHERE r.ProductServiceID= 14 AND c.RegionID=1 AND c.IsActive = 1 ORDER BY r.`ReportID` DESC ;
I want to remove the 2nd duplicate ComapnyID in result
I have tried these queries
Distinct Inner join Group by with having
if I change the query and get distinct data than the order gets change which I don't want.