1

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")
3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by jlego
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.