Hi experts,This code below works very well in Access:SELECT DISTINCT c.carTypes, h.hourly, h.hourly * SWITCH([CarTypes] = 'Sedan', 55 ,[CarTypes] = 'Stretch Limo : 6 Passenger', 75 ,[CarTypes] = 'Stretch Limo : 8 Passenger', 90 ,[CarTypes] = 'Stretch Limo : 10 Passenger', 95 ,[CarTypes] = 'Stretch Limo : 12 Passenger', 110 ,[CarTypes] = 'SportUtilityVehicle', 110 ) AS Fare , Fare*10/100 AS Discount , Fare-Discount AS NewFare , NewFare*7/100 AS Tax , NewFare*20/100 AS Tip , NewFare+Tax+TIP AS TotalFROM HourlyRates AS h INNER JOIN carType AS c ON h.ID= c.hourlyID;
However, when I try to run what I call the equivalence in sql server, I get errors:SELECT DISTINCT c.carTypes, h.hourly, h.hourly *(CASE [CarTypes] WHEN 'Sedan' Then 55 WHEN 'Stretch Limo : 6 Passenger' Then 75 WHEN 'Stretch Limo : 8 Passenger' Then 90 WHEN 'Stretch Limo : 10 Passenger' Then 95 WHEN 'Stretch Limo : 12 Passenger' Then 110 WHEN 'SportUtilityVehicle' Then 110 ELSE '' END) As Fare , Fare*10/100 AS Discount , Fare-Discount AS NewFare , NewFare*7/100 AS Tax , NewFare*20/100 AS Tip , NewFare+Tax+TIP AS Total FROM HourlyRates AS h INNER JOIN carType AS c ON h.ID= c.hourlyID;
The error says following are invalid colum names: , Fare*10/100 AS Discount , Fare-Discount AS NewFare , NewFare*7/100 AS Tax , NewFare*20/100 AS Tip , NewFare+Tax+TIP AS TotalAny ideas?Thanks in advance