CREATE VIEW ThresholdsView AS
SELECT
server_addr=0
,probe_addr=0
,MibIdx=0
,rsrcIndex=0
,rsrcOtherIndex=0
,td.fieldIndex
,fieldName=lower(td.fieldName)
,lowerThreshold=displayScaleFactor*td.lowerDefaultValue
,lowerMode=td.lowerDefaultMode
,upperThreshold=displayScaleFactor*td.upperDefaultValue
,upperMode=td.upperDefaultMode
FROM ThresholdDesc td
UNION ALL
SELECT t.server_addr
,t.probe_addr
,t.MibIdx
,t.rsrcIndex
,t.rsrcOtherIndex
,td.fieldIndex
,fieldName=lower(td.fieldName)
,lowerThreshold=displayScaleFactor*(
CASE lowerMode
WHEN 2 THEN td.lowerDefaultValue
WHEN 3 THEN 0
ELSE t.lowerThreshold
END)
,t.lowerMode
,upperThreshold=displayScaleFactor*(
CASE upperMode
WHEN 2 THEN td.upperDefaultValue
WHEN 3 THEN 0
ELSE t.upperThreshold
END)
,t.upperMode
FROM Thresholds t JOIN ThresholdDesc td ON
t.fieldIndex=td.fieldIndex
GO
GRANT SELECT ON [dbo].[ThresholdsView] TO [uniadmin]
GO