Is this possible to recreate using llblgen?
SELECT
GroupId
,A.Description
,ISNULL(myCount,0) AS 'Count'
FROM Products_Groups A LEFT OUTER JOIN
(SELECT ProductGroupId,COUNT(*) AS 'myCount'
FROM Products_Machines
WHERE AvailableId = @AvailableId
GROUP BY ProductGroupId) B ON A.GroupID = B.ProductGroupId
ORDER BY Count DESC
This gives me
1 aaa 30
2 bbb 10
3 ccc 5
4 ddd 0
I don't think I can the the last record without going the sub query route.
VB 2005
Self Serving 2.0.0.60523