select query and group by in sqlserver
-
hi, have a problem i want to select all records from left table and corresponding records from right table using group by clause. my tsqlstatement is select A.CatId,A.CategoryName,A.CategoryImage, Count(B.ProductId),count(B.SubCatId) from Tbl_Category as A Left outer join Tbl_CategoryWiseProduct as B on A.CatId=B.CatId group by A.CatId,A.CategoryName,A.CategoryImage but is does not working properly help
-
hi, have a problem i want to select all records from left table and corresponding records from right table using group by clause. my tsqlstatement is select A.CatId,A.CategoryName,A.CategoryImage, Count(B.ProductId),count(B.SubCatId) from Tbl_Category as A Left outer join Tbl_CategoryWiseProduct as B on A.CatId=B.CatId group by A.CatId,A.CategoryName,A.CategoryImage but is does not working properly help
This query looks like yours, I performed it on Northwind database, and it works : select Categories.CategoryId, Categories.CategoryName, count(products.productid) as total from Categories, Products where Categories.Categoryid = Products.Categoryid group by Categories.categoryid, Categories.Categoryname Hope this will help you. What's the meaning (in business terms) of SubCatId?