I have the below SQL statement which works. My challenge is that I need to do the same count of the category codes but multiple times for different values. So as an example (((Count(tbl_Asset_Inspection.CATEGORY_CODE))=2)), (((Count(tbl_Asset_Inspection.CATEGORY_CODE))=3)), etc.
Thank you for your help.
SELECT tbl_Unit.Name, tbl_Unit.Location, tbl_Asset_Inspection.NSN, tbl_Asset.NOMENCLATURE, tbl_LocationAssets.CAT_III, tbl_LocationAssets.CAT_IV, tbl_LocationAssets.CAT_II_IV, Count(tbl_Asset_Inspection.CATEGORY_CODE) AS CountOfCATEGORY_CODEFROM tbl_Asset INNER JOIN ((tbl_LocationAssets INNER JOIN tbl_Asset_Inspection ON tbl_LocationAssets.iAssetID = tbl_Asset_Inspection.iParentID) INNER JOIN tbl_Unit ON tbl_LocationAssets.iParentID = tbl_Unit.iParentID) ON tbl_Asset.ID = tbl_Asset_Inspection.iParentIDGROUP BY tbl_Unit.Name, tbl_Unit.Location, tbl_Asset_Inspection.NSN, tbl_Asset.NOMENCLATURE, tbl_LocationAssets.CAT_III, tbl_LocationAssets.CAT_IV, tbl_LocationAssets.CAT_II_IVHAVING (((Count(tbl_Asset_Inspection.CATEGORY_CODE))=1))
That way, you obtain all count of tbl_Asset_Inspection.CATEGORY_CODE.
paiman01
ASKER
Hello,
Thank you for your response. I am not sure if that would work. I need to create a column which contains a count of CATEGORY_CODE based on condition. Then solution would contain 5 columns one for the count on CATEGORY_CODE where the value is equal 1, then second count on CATEGORY_CODE where the value is equal 2, etc. I need this one SQL so that i can take the results into CrystalReports.
Open in new window