Guest User

Untitled

a guest
Sep 6th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. SELECT
  2. vw_Items.ID
  3. ,vw_Items.ResolvedEntityID
  4. ,vw_Items.ResolvedDescription
  5. ,vw_Items.ItemProductNumber
  6. ,vw_Items.ItemDescription
  7. ,vw_Items.FilteringType
  8. ,vw_Items.ItemCategory
  9. ,vw_Items.IsDefault
  10. ,vw_Items.IsInventoryType
  11. ,vw_Items.Active
  12. ,vw_Items.PlantFloorVisible
  13. ,[dbo].f_ParseDistanceValue([Length]) AS 'Length'
  14. ,[dbo].f_ParseDistanceValue(Width) AS Width
  15. ,ISNULL(MaterialDescription.[Description], '(none)') AS 'Material'
  16. ,ISNULL(GradeDescription.[Description], '(none)') AS 'Grade'
  17. ,ISNULL(MillingDescription.[Description], '(none)') AS 'Milling'
  18. ,ISNULL(StateDescription.[Description], '(none)') AS 'State'
  19. FROM
  20. vw_Items
  21. -- Join to get properties
  22. left join (
  23. select [ItemEntityID],[Property],[Value] from [dbo].[ItemProperties]) p
  24. PIVOT (MAX(VALUE) for [Property] in (Material,Grade,Milling,State,Length,Width))properties on vw_Items.[EntityID] = properties.[ItemEntityID]
  25. LEFT JOIN DescriptionEntity AS MaterialDescription ON properties.Material = MaterialDescription.EntityID
  26. LEFT JOIN DescriptionEntity AS GradeDescription ON properties.Grade = GradeDescription.EntityID
  27. LEFT JOIN DescriptionEntity AS MillingDescription ON properties.Milling = MillingDescription.EntityID
  28. LEFT JOIN #DescriptionEntity AS StateDescription ON properties.[State] = StateDescription.EntityID
Advertisement
Add Comment
Please, Sign In to add comment