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")

What does "not properly" mean?

Select data from table group by storeid

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.