SELECT CONVERT(VARCHAR, I.EntryDate, 101) AS [Entry Date],
CASE WHEN LastUpdate = CAST('Jan 1 1980' AS DateTime) THEN ''
WHEN LastUpdate = CAST('Dec 30 1899' AS DateTime) THEN ''
ELSE CONVERT(varchar, LastUpdate, 101) END AS [Last Updated],
I.product_code AS [Product Code], I.descriptionV6 AS [Internal Description], I.PrintedDesc AS [Printed Description],
CASE WHEN I.product_Config = 0 THEN 'Single Item'
WHEN I.product_Config = 1 THEN 'Package'
WHEN I.product_Config = 2 THEN 'Macro'
ELSE '** E **' END AS [Product Configuration],
CASE WHEN I.product_type_v41 = 0 THEN 'Rental Item'
WHEN I.product_type_v41 = 1 THEN 'Labour Item'
WHEN I.product_type_v41 = 2 THEN 'Technician'
WHEN I.product_type_v41 = 3 THEN 'Sales Item'
ELSE '** E **' END AS [Product Type],
I.indiv_hire_sale AS [For Individual Hire/Sale], I.on_hand AS [Qty On Hand], I.isGenericItem as [Is Generic Item], I.IsInTrashCan AS [Is in Trash Can],
I.unit_weight as [Unit Weight], I.CountryOfOrigin as [Country of Origin],
I.groupFld as [Group Code], isnull(g.group_descV6,'') as [Group Description], I.category as [Category Code], isnull(C.cat_descV6,'') as [Category Description],
isnull(I.SubCategory,'') as [Sub Category Code], isnull(SC.cat_descV6,'') as [Sub Category Description]
FROM tblInvmas AS I
LEFT OUTER JOIN tblGroup AS G ON G.Group_code = I.groupFld
LEFT OUTER JOIN tblCategory AS C ON C.category_code = I.category
LEFT OUTER JOIN tblCategory AS SC ON SC.category_code = I.SubCategory
WHERE I.product_type_v41 IN (0,3)
ORDER BY I.EntryDate DESC, I.ID