I looked at the dynamic list example and I modified the way I fetch typed list and it generated following statement:
SELECT DISTINCT [PublishedUserAlertDetail].[PublishedUserAlertDetailId],
[PublishedUserAlert].[OrganizationCode],
[PublishedUserAlert].[OrganizationName],
[PublishedUserAlert].[Message],
[PublishedUserAlertDetail].[DetailMessage],
[PublishedUserAlert].[DateProcessed],
[PublishedUserAlertDetailComment].[Comment],
[PublishedUserAlert].[CategoryName],
[PublishedUserAlert].[TypeName],
[PublishedUserAlertDetail].[CurrentStateFlag],
MAX([PublishedUserAlertDetailComment].[CommentDate]) AS[CommentDate]
FROM [PublishedUserAlert]
INNER JOIN [PublishedUserAlertDetail]
ON [PublishedUserAlert].[PublishedUserAlertId]=[PublishedUserAlertDetail].[PublishedUserAlertId]
LEFT JOIN [PublishedUserAlertDetailComment]
ON [PublishedUserAlertDetail].[PublishedUserAlertDetailId]=[PublishedUserAlertDetailComment].[PublishedUserAlertDetailId]
--WHERE ( ( ( [PublishedUserAlert].[UserId] = 14 AND [PublishedUserAlert].[OrganizationCode]
-- IN (001, 041, 042, 043, 044, 045)
-- AND [PublishedUserAlertDetail].[CurrentStateFlag] <> 'R')))
GROUP BY
[PublishedUserAlertDetail].[PublishedUserAlertDetailId]
[PublishedUserAlert].[OrganizationCode],
[PublishedUserAlert].[OrganizationName],
[PublishedUserAlert].[Message],
[PublishedUserAlertDetail].[DetailMessage],
[PublishedUserAlert].[DateProcessed],
[PublishedUserAlertDetailComment].[Comment],
[PublishedUserAlert].[CategoryName],
[PublishedUserAlert].[TypeName],
[PublishedUserAlertDetail].[CurrentStateFlag]
however this is not producing the result that I need as I get all detailcomments not just the max ones, as the groupby clause contains grouping by all fileds that are in select list not just the PublishedUserAlertDetailId. Need to figure out a way to do this. Basically I need a last comment that was made to the alert to be included in the list so I can show it to the user in the grid. Anyway thanks for you help.