Hi
I am using the following join query to get a list of stores that have sold policies during the day.
But I need it to be distinct
$Query = mysql_query("SELECT tblpolicies.StoreId
, tblpolicies.DateReceived
, DailyGroup.GroupName
, DailyGroup.StoreName
, DailyGroup.PortfolioName
FROM tblpolicies
LEFT OUTER
JOIN (SELECT StoreId
, GroupName, StoreName, PortfolioName
FROM tblstores GROUP BY StoreId) AS DailyGroup
ON tblpolicies.storeId = DailyGroup.StoreId
WHERE DateReceived ='2010-07-01' ORDER BY GroupName
When I try using DISTINCT it doesnt work properly
$Query = mysql_query("SELECT DISTINCT tblpolicies.StoreId
, tblpolicies.DateReceived
, DailyGroup.GroupName
, DailyGroup.StoreName
, DailyGroup.PortfolioName
FROM tblpolicies
LEFT OUTER
JOIN (SELECT StoreId
, GroupName, StoreName, PortfolioName
FROM tblstores GROUP BY StoreId) AS DailyGroup
ON tblpolicies.storeId = DailyGroup.StoreId
WHERE DateReceived ='2010-07-01' ORDER BY GroupName")