I got that far: Here's what I have and I'm not sure what
to do with respect to the expression names (Quarter,
Positive_Infection, Short_CVAD, Long_CVAD) I am figuring I
need to declare them but where do I do this?
Thanks
Candace
Alter PROCEDURE Sub_Annual_Histogram @Start_Date
datetime, @End_Date datetime, @Nursing_Unit nvarchar(25),
@Team nvarchar(50), @Program nvarchar(50), @Type_of_Vein
nvarchar(20)
AS SELECT CASE WHEN ((Month(dbo.Day_CVAD_Date) = 4 OR Month
(dbo.Day_CVAD_Date) = 5 OR Month(dbo.Day_CVAD_Date) = 6))
THEN Quarter = 1 as Quarter
WHEN ((Month(dbo.Day_CVAD_Date) = 7 OR Month
(dbo.Day_CVAD_Date) = 8 OR Month(dbo.Day_CVAD_Date) = 9)
THEN Quarter = 2 as Quarter
WHEN ((Month(dbo.Day_CVAD_Date) = 10 OR Month
(dbo.Day_CVAD_Date) = 11 OR Month(dbo.Day_CVAD_Date) = 12)
THEN Quarter = 3 as Quarter
WHEN ((Month(dbo.Day_CVAD_Date) = 1 OR Month
(dbo.Day_CVAD_Date) = 2 OR Month(dbo.Day_CVAD_Date) = 3))
THEN Quarter = 4 as Quarter
CASE WHEN (dbo.Infection_Nosocomial = 'Yes' AND
(dbo.Infection_Type = 'Blood' OR dbo.Infection_Type
= 'Both')) THEN Positive_Infection = 1
ELSE Positive_Infection = 0 as Positive_Infection
CASE WHEN (dbo.Device_CVAD_Length = 'Short ') THEN
Short_CVAD = 1
ELSE Short_CVAD = 0 as Short_CVAD
CASE WHEN (dbo.Device_CVAD_Length = 'Long') THEN
Long_CVAD = 1
ELSE Long_CVAD = 0 as Long_CVAD
FROM dbo.Device INNER JOIN
dbo.Day ON
dbo.Device.Device_New_CVAD_ID = dbo.Day.Day_New_CVAD_ID
INNER JOIN
dbo.Patient_Care_Area ON
dbo.Day.Day_Patient_Care_Area_ID =
dbo.Patient_Care_Area.Patient_Care_Area_ID
INNER JOIN
dbo.Infection ON
dbo.Day.Day_ID = dbo.Infection.Infection_Day_ID
WHERE (dbo.Patient_Care_Area.Patient_Care_Area_Program
LIKE @Program) AND
(dbo.Patient_Care_Area.Patient_Care_Area_Team_Grouping
LIKE @Team) AND
(dbo.Patient_Care_Area.Patient_Care_Area_Nursing_Unit
LIKE @Nursing_Unit) AND
(dbo.Device.Device_Vein_Line LIKE @Type_of_Vein) AND
(dbo.Day.Day_CVAD_Date BETWEEN @Start_Date AND
@End_Date))
-----Original Message-----
IIF statements become CASE statements in SQL Server stored procedures
--
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
How do you write a nested Iif statement in a view or a
stored procedure?
Listed below is what I have in a query in Access, I
realize [Day_CVAD_Date] will become dbo.Day_CVAD_Date and
I'm assuming the word Quarter is in my Alias column. So
specifically my question is what syntax do I use in
my 'Column' column?
Quarter: IIf(Month([Day_CVAD_Date])=4 Or Month
([Day_CVAD_Date])=5 Or Month([Day_CVAD_Date])=6,1,IIf (Month
([Day_CVAD_Date])=7 Or Month([Day_CVAD_Date])=8 Or Month
([Day_CVAD_Date])=9,2,IIf(Month([Day_CVAD_Date])=10 Or
Month([Day_CVAD_Date])=11 Or Month([Day_CVAD_Date])
=12,3,IIf(Month([Day_CVAD_Date])=1 Or Month
([Day_CVAD_Date])=2 Or Month([Day_CVAD_Date])=3,4,0))))
Candace
.