I can receive the correct results when used as a querey, but I would like to turn it into a view. Enterprise Manager will not accept CASE when attempting to create the view.
Here is my querey:
SELECT dbo.INCOME.ID, SUM(CASE WHEN dbo.INCOME.RENT_UNIT_TYPE = 'sf' THEN '1' ELSE dbo.INCOME.RENT_UNITS END) AS 'Rental_Units'
FROM dbo.INCOME INNER JOIN dbo.YEAR ON dbo.INCOME.YEAR_ID = dbo.YEAR.CURRENT_FY
GROUP BY dbo.INCOME.ID
ORDER BY dbo.INCOME.ID
sample data
ID / RENT_Unit_Type / Rent_Units
01 / sf / 1212
01 / sf / 2100
02 / u / 1
03 / u / 5
04 / sf / 567
04 / sf / 1345
04 / u / 1
I am trying to get it to tell me the number of units. every time 'sf' appears, it represents 1 unit. everytime 'u' appears, it is the actual number of units. so to make each time 'sf' is found equal 1, then add it to the number of 'u' for each unique ID.
this is what I would like to recieve:
ID / Rental_Units
01 / 2
02 / 1
03 / 5
04 / 3